/* LocalHub styles with sidebar tree and logs */
:root{
  --bg: #0b0c0f;
  --bg-panel: #111317;
  --border: #22252b;
  --text: #f2f3f5;
  --muted: #a9b0bb;
  --link: #7aa2ff;
  --accent: #9cdcfe;
  --good: #7ee787;
  --warn: #f9c513;
  --danger: #f85149;
}

@media (prefers-color-scheme: light) {
  :root{
    --bg: #fafbfc;
    --bg-panel: #ffffff;
    --border: #e6e8eb;
    --text: #0a0b0e;
    --muted: #6b7280;
    --link: #0969da;
    --accent: #005cc5;
    --good: #1a7f37;
    --warn: #bf8700;
    --danger: #cf222e;
  }
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin:0;
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial;
  color: var(--text);
  background: var(--bg);
}

.container{ max-width: 1200px; margin: 0 auto; padding: 1rem; }

.topbar{ position: sticky; top: 0; z-index: 20; background: var(--bg-panel); border-bottom: 1px solid var(--border); }
.topbar-inner{ display: flex; align-items: center; justify-content: space-between; }
.brand-title{ color: var(--text); text-decoration: none; font-weight: 700; }
.brand-subtitle{ color: var(--muted); margin-left: .5rem; }
.top-actions .btn{ margin-left: .5rem; }
.chip{ margin-left:.6rem; border:1px solid var(--border); padding:.1rem .4rem; border-radius:999px; font-size:.8rem; color: var(--good); }

/* Layout with sidebar */
.layout{ display: grid; grid-template-columns: 280px 1fr; gap: 1rem; }
.sidebar{ border: 1px solid var(--border); background: var(--bg-panel); border-radius: 10px; overflow: hidden; }
.sidebar-h{ padding:.6rem .8rem; border-bottom:1px solid var(--border); color: var(--muted); font-weight:600; }
.tree{ padding:.4rem .3rem 1rem .3rem; max-height: calc(100vh - 220px); overflow:auto; }
.content{ min-width:0; }

.footer{ border-top: 1px solid var(--border); color: var(--muted); display:flex; justify-content: space-between; gap:1rem; font-size:.9rem; padding-bottom:2rem; }

.breadcrumbs{ margin: 1rem 0; color: var(--muted); }
.breadcrumbs a{ color: var(--link); text-decoration: none; }
.breadcrumbs .sep{ margin: 0 .5rem; color: var(--muted); }

.panel{ border: 1px solid var(--border); background: var(--bg-panel); border-radius: 10px; margin-bottom: 1rem; overflow: hidden; }
.panel-h{ display:flex; align-items:center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.panel-h h2, .panel-h h3{ margin: 0; font-size: 1.1rem; }
.panel-actions .btn{ margin-left: .5rem; }

.btn{ display:inline-block; border:1px solid var(--border); background: transparent; color: var(--text); padding:.4rem .7rem; border-radius:8px; text-decoration:none; cursor:pointer; }
.btn:hover{ border-color: var(--link); color: var(--link); }
.btn.danger{ border-color: var(--danger); color: var(--danger); }

.input{ border:1px solid var(--border); background: transparent; color: var(--text); padding:.4rem .6rem; border-radius:8px; min-width: 240px; }

.file-list{ width: 100%; }
.file-list-h{ display:grid; grid-template-columns: 1fr 180px 120px; gap:.5rem; padding:.5rem 1rem; color: var(--muted); border-bottom: 1px solid var(--border); font-size: .9rem; }
.file-row{ display:grid; grid-template-columns: 1fr 180px 120px; align-items:center; gap:.5rem; padding:.6rem 1rem; text-decoration:none; color: var(--text); border-bottom: 1px solid var(--border); }
.file-row:hover{ background: rgba(127,127,127,.08); }
.file-row .name{ display:flex; align-items:center; gap:.6rem; }
.file-row .ico{ width: 1.25rem; text-align:center; }
.file-row.up{ color: var(--link); }
.file-row .meta{ color: var(--muted); font-variant-numeric: tabular-nums; }
.file-row .meta-right{ text-align:right; }

.viewer{ padding: 1rem; }
.media-center{ display:flex; justify-content:center; align-items:center; }
.media-center img{ max-width:100%; height:auto; border-radius:8px; }
.pdf-frame{ width: 100%; height: 80vh; border: none; }

/* Markdown body */
.markdown-body{ line-height: 1.7; font-size: 1rem; }
.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4{ border-bottom: 1px solid var(--border); padding-bottom: .2rem; }
.markdown-body code{ background: rgba(127,127,127,.15); padding: .1rem .3rem; border-radius: 4px; }
.markdown-body pre{ background: rgba(127,127,127,.12); padding: 1rem; overflow:auto; border-radius:10px; }
.markdown-body table{ border-collapse: collapse; width: 100%; }
.markdown-body th,.markdown-body td{ border:1px solid var(--border); padding:.4rem .6rem; }
.markdown-body blockquote{ border-left: 4px solid var(--border); margin: .8rem 0; padding: .2rem .8rem; color: var(--muted); }
.markdown-body img{ max-width: 100%; height: auto; }

.code-block{ overflow:auto; border-radius:10px; background: rgba(127,127,127,.12); padding: 1rem; }

/* CSV/Excel tables */
.csv-table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.9rem; }
.csv-table th, .csv-table td { border: 1px solid var(--border); padding: .3rem .5rem; text-align: left; }
.csv-table th { background: rgba(127,127,127,.15); }
.table-wrap { overflow-x: auto; }

/* Script runner */
.run-block{ margin-bottom: 1rem; }
.run-row{ display:flex; gap:.5rem; align-items:center; margin-bottom:.5rem; }
.log{ background:#000; color:#d2f8d2; padding: .75rem; border-radius:8px; min-height: 120px; white-space: pre-wrap; }

/* Tree */
.tree ul{ list-style:none; padding-left: 1rem; }
.tree .node{ display:flex; align-items:center; gap:.35rem; padding:.2rem .4rem; border-radius:6px; cursor:pointer; }
.tree .node:hover{ background: rgba(127,127,127,.09); }
.tree .caret{ width: 1rem; text-align:center; display:inline-block; }
.tree .folder{ color: var(--text); }
.tree .file{ color: var(--text); text-decoration:none; display:block; padding:.2rem .4rem; border-radius:6px; }
.tree .file:hover{ background: rgba(127,127,127,.09); }

/* Small screens */
@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; }
  .sidebar{ display:none; }
}

.tree .active { outline: 1px dashed var(--link); background: rgba(127,127,255,.08); border-radius:6px; }
.tree .file.active, .tree .node.active { color: var(--link); }

