/*
 * Dashboard styles.
 *
 * Chart colors follow the data-viz reference palette; the single data hue is
 * validated against both surfaces (all six checks pass, light and dark). The
 * brand green is UI-only — buttons and links — and never encodes data.
 */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --deemph: #d7d6d0;
  --good: #006300;
  --accent: #1a7f5a;
  --accent-fg: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #fff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --deemph: #35342f;
    --good: #0ca30c;
    --accent: #3ddc97;
    --accent-fg: #08120d;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* The dashboard is an app surface: no page-level rubber-banding. iOS's
   bounce past the last card showed a full screen of raw background that
   testers read as broken spacing (Saurabh, 2026-08-26). */
html { overscroll-behavior-y: none; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 64px; }

/* ---------- chrome ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: 8px 0 20px; }
.top .brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.top .spacer { flex: 1; }
.who { color: var(--text-secondary); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); font: inherit;
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--baseline); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: default; }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.card .sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }
.head { display: flex; align-items: flex-start; gap: 12px; }
.head .spacer { flex: 1; }

/* ---------- filter row: one row above everything it scopes ---------- */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button {
  padding: 8px 14px; border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg button[aria-pressed='true'] { background: var(--accent); color: var(--accent-fg); }

/* ---------- stat tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi .label { color: var(--text-secondary); font-size: 13px; margin-bottom: 6px; }
/* proportional figures — tabular-nums makes large numbers look loose */
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .foot { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.grid-line { stroke: var(--grid); stroke-width: 1; }        /* solid hairline, never dashed */
.axis-line { stroke: var(--baseline); stroke-width: 1; }
.tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.bar { fill: var(--series-1); }
.bar-hit { fill: transparent; cursor: pointer; }
.bar-hit:hover + .bar, .bar-hit:focus + .bar { opacity: .82; }
.dlabel { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.empty-note { color: var(--text-muted); font-size: 13px; padding: 28px 0; text-align: center; }

.tip {
  position: fixed; pointer-events: none; z-index: 30; opacity: 0;
  background: var(--text-primary); color: var(--surface-1);
  padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.35;
  transition: opacity .12s; white-space: nowrap;
}
.tip.show { opacity: 1; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
.name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); }
.tableview { display: none; }
.tableview.show { display: block; }

/* File/folder tables scroll inside their own card, never the page. */
#files, #folders { overflow-x: auto; }
/* Name cell: small poster (or type glyph) beside an ellipsised name. */
.namecell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fthumb { width: 44px; height: 30px; border-radius: 6px; object-fit: cover; flex: none; background: var(--deemph); }
.fthumb.ph { display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
/* Actions: one aligned row, same order every row. */
.actcell { text-align: right; }
.actions { display: inline-flex; gap: 6px; white-space: nowrap; }
/* Upload date. Never wraps — a date broken over two lines reads as two dates. */
td.date, th.date { white-space: nowrap; color: var(--text-secondary); }
/* Sub-line under the filename: compressed-to size, and the date on a phone. */
.fsub { font-size: 12px; opacity: .7; margin-top: 2px; }
.fdate { display: none; }

/* Phones: drop the stat columns (they live in Analytics) and compact the
   buttons so name + actions share one line, nothing off-screen. The date
   joins the size sub-line rather than being dropped — creators asked for it
   precisely to tell two uploads of the same video apart, and they do that
   here. Files are columns 3/4 (Views/Visibility) now that Uploaded sits at 2;
   folders have no date column and keep 2/3. */
@media (max-width: 720px) {
  #files th.date, #files td.date,
  #files th:nth-child(3), #files td:nth-child(3):not([colspan]),
  #files th:nth-child(4), #files td:nth-child(4),
  #folders th:nth-child(2), #folders td:nth-child(2),
  #folders th:nth-child(3), #folders td:nth-child(3) { display: none; }
  #files .fdate { display: inline; }
  #files .name, #folders .name { max-width: 36vw; }
  #files .btn.sm, #folders .btn.sm { padding: 5px 8px; font-size: 12px; }
  .fthumb { width: 38px; height: 26px; }
}

/* ---------- upload ---------- */
.drop {
  border: 1.5px dashed var(--baseline); border-radius: 12px; padding: 28px;
  text-align: center; color: var(--text-secondary); cursor: pointer;
}
.drop.over { border-color: var(--accent); color: var(--text-primary); }
.prog { height: 6px; background: var(--deemph); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.prog > i { display: block; height: 100%; width: 0; background: var(--series-1); transition: width .15s; }
.uprow { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); margin-top: 10px; gap: 10px; }

/* ---------- login ---------- */
.login { max-width: 380px; margin: 8vh auto; }
.login input {
  width: 100%; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); font: inherit; margin-bottom: 10px;
}
.err { color: #d03b3b; font-size: 13px; min-height: 18px; }
.msg { color: var(--good); font-size: 13px; min-height: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140%);
  background: var(--text-primary); color: var(--surface-1); padding: 10px 18px;
  border-radius: 999px; font-size: 14px; transition: transform .22s; z-index: 40;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.hide { display: none !important; }

/* ---------- admin panel ---------- */
.formrow { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.formrow label {
  display: flex; flex-direction: column; gap: 6px;
  color: var(--text-secondary); font-size: 13px; min-width: 200px; flex: 1;
}
.formrow input, .formrow select, .formrow textarea {
  padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); font: inherit;
}
.formrow textarea { font-family: ui-monospace, monospace; font-size: 12px; resize: vertical; }
.tablewrap { overflow-x: auto; }
.tbl input.rate {
  width: 90px; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); font: inherit;
  font-variant-numeric: tabular-nums; text-align: right;
}
.tbl .muted { color: var(--text-muted); }

/* ---------- DiskWala-style dashboard shell (dark, sidebar) ---------- */
body.dwdark {
  color-scheme: dark;
  --surface-1: #131614;
  --page: #0a0c0b;
  --text-primary: #f2f5f3;
  --text-secondary: #b8c0bb;
  --text-muted: #7d857f;
  --grid: #232724;
  --baseline: #333834;
  --border: rgba(255, 255, 255, 0.08);
  --series-1: #3987e5;
  --deemph: #2a2e2b;
  --good: #21c25f;
  --accent: #2fdc7f;
  --accent-fg: #05160c;
}

.dash { display: flex; min-height: 100vh; }

.side {
  width: 242px; flex-shrink: 0; background: #0e110f;
  border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand {
  font-weight: 800; font-size: 18px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 9px; padding: 4px 10px 14px;
}
.side-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 10px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; text-transform: uppercase;
}
.side-user-t { min-width: 0; }
.side-name { display: block; font-weight: 600; font-size: 14px; }
.side-mail {
  display: block; color: var(--text-muted); font-size: 12px;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-label {
  color: var(--text-muted); font-size: 11px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; padding: 14px 10px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 10px; color: var(--text-secondary); text-decoration: none;
  font-weight: 600; font-size: 14px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.nav-item.active { background: rgba(47, 220, 127, 0.14); color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; stroke: currentColor; flex-shrink: 0; }
.side-spacer { flex: 1; }
.side-bottom { display: flex; flex-direction: column; gap: 8px; padding: 8px 6px 4px; }

.main { flex: 1; min-width: 0; padding: 24px 28px 28px; display: flex; flex-direction: column; }
.main > section { flex: 1; }
/* Footer pinned to the true end of the page — the dashboard stops looking
   like it trails off into empty space when scrolled past the last card. */
.dash-foot {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-muted);
}
.dash-foot a { color: var(--text-muted); text-decoration: none; }
.dash-foot a:hover { color: var(--text-secondary); }
.main > section { max-width: 1000px; }
.page-title { font-size: 21px; font-weight: 700; margin: 0 0 16px; letter-spacing: -0.01em; }

/* phone: the sidebar folds into a top bar with a scrollable nav row */
@media (max-width: 860px) {
  .dash { flex-direction: column; }
  .side {
    position: static; width: 100%; height: auto; overflow: visible;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px;
    border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 12px;
  }
  .side-brand { padding: 0 8px 0 0; }
  .side-user, .side-label { display: none; }
  .nav-item { padding: 8px 10px; font-size: 13px; }
  .nav-item svg { width: 16px; height: 16px; }
  .side-spacer { flex: 1; }
  .side-bottom { flex-direction: row; padding: 0; }
  .main { padding: 18px 14px 20px; }
}
