/* GEARVN Video DB Preview — design tokens + layout. */

:root {
  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --footer-h: 56px;
  --radius: 10px;
  --radius-sm: 6px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg:          #0a0d12;
  --bg-elev:     #11161e;
  --bg-elev-2:   #161c26;
  --bg-hover:    #1a2230;
  --border:      #1f2937;
  --border-strong: #2d3849;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-subtle: #6e7681;
  --accent:      #6ea8fe;
  --accent-soft: rgba(110,168,254,.14);
  --success:     #3fb950;
  --warn:        #d29922;
  --danger:      #f85149;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
}

[data-theme="light"] {
  --bg:          #f7f8fa;
  --bg-elev:     #ffffff;
  --bg-elev-2:   #ffffff;
  --bg-hover:    #f1f4f9;
  --border:      #e5e9f0;
  --border-strong: #cfd6e0;
  --text:        #1c2128;
  --text-muted:  #57606a;
  --text-subtle: #8b949e;
  --accent:      #0969da;
  --accent-soft: rgba(9,105,218,.08);
  --success:     #1a7f37;
  --warn:        #9a6700;
  --danger:      #cf222e;
  --shadow:      0 4px 12px rgba(140,149,159,.15);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 20px 18px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #b794f4);
  color: white;
  border-radius: 8px;
  font-size: 18px;
}
.brand-title { font-weight: 700; font-size: 14px; letter-spacing: .2px; }
.brand-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.nav { flex: 1; padding: 8px 10px; }
.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-subtle);
  padding: 14px 8px 6px;
  font-weight: 600;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-icon {
  font-size: 14px;
  display: grid; place-items: center;
  opacity: .85;
}
.nav-label { font-size: 13px; }
.nav-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
  background: var(--bg-elev-2);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 500;
}
.nav-item.active .nav-count { background: var(--accent-soft); color: var(--accent); }

.sidebar-foot {
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.theme-toggle {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: background .14s;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
[data-theme="dark"] .theme-light { display: inline; }
[data-theme="dark"] .theme-dark  { display: none; }
[data-theme="light"] .theme-light { display: none; }
[data-theme="light"] .theme-dark  { display: inline; }

.github-link {
  font-size: 11px;
  color: var(--text-subtle);
  text-decoration: none;
  font-family: var(--font-mono);
}
.github-link:hover { color: var(--accent); }

/* ── Main ────────────────────────────────────────────────────── */
.main {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--footer-h);
  height: 100vh;
  overflow: hidden;
}

.topbar {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg);
}
.topbar-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.2px;
}
.topbar-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  width: 320px;
  transition: border-color .14s, box-shadow .14s;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-icon { color: var(--text-subtle); font-size: 14px; }
.search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  flex: 1;
  padding: 8px 0;
}
.search input::placeholder { color: var(--text-subtle); }
.search-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-elev-2);
  color: var(--text-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.btn-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: background .14s, color .14s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

/* ── Content / Table ────────────────────────────────────────── */
.content {
  position: relative;
  overflow: auto;
  background: var(--bg);
}

.table-wrap { padding: 16px 24px; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  white-space: nowrap;
}
thead th:first-child {
  border-top-left-radius: var(--radius-sm);
  border-left: 1px solid var(--border);
}
thead th:last-child {
  border-top-right-radius: var(--radius-sm);
  border-right: 1px solid var(--border);
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  max-width: 360px;
}
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--bg-hover); }
tbody td:first-child { border-left: 1px solid var(--border); }
tbody td:last-child  { border-right: 1px solid var(--border); }
tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-sm); }
tbody tr:last-child td:last-child  { border-bottom-right-radius: var(--radius-sm); }

td.num, td .mono { font-family: var(--font-mono); font-size: 12px; }
td a { color: var(--accent); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }
td .null { color: var(--text-subtle); font-style: italic; font-size: 12px; }
td .truncate {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 380px;
}

/* Score pills */
.score-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.score-high { background: rgba(63,185,80,.14); color: var(--success); }
.score-med  { background: rgba(210,153,34,.14); color: var(--warn); }
.score-low  { background: rgba(248,81,73,.14); color: var(--danger); }

/* Tag pill */
.tag-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}

/* Type pill */
.type-pill {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.type-long  { background: var(--accent-soft); color: var(--accent); }
.type-short { background: rgba(180,148,244,.14); color: #b794f4; }

/* Lang pill */
.lang-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-elev-2);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* ── Footer / Pagination ─────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elev);
}
.footer-info {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.pagination { display: flex; align-items: center; gap: 6px; }
.btn-page {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: background .12s, opacity .12s;
}
.btn-page:hover:not(:disabled) { background: var(--bg-hover); }
.btn-page:disabled { opacity: .35; cursor: not-allowed; }
.page-indicator {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 10px;
  min-width: 40px;
  text-align: center;
}

/* ── States ──────────────────────────────────────────────────── */
.hidden { display: none !important; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(2px);
  z-index: 10;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 80px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 36px; color: var(--text-subtle); margin-bottom: 8px; }
.empty-title { font-weight: 600; font-size: 16px; color: var(--text); margin-bottom: 4px; }
.empty-hint { font-size: 13px; color: var(--text-muted); }

.error {
  margin: 16px 24px;
  padding: 14px 16px;
  background: rgba(248,81,73,.08);
  border: 1px solid rgba(248,81,73,.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }
  .brand > div, .nav-label, .nav-section, .sidebar-foot .github-link { display: none; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; }
  .nav-count { font-size: 9px; padding: 1px 4px; }
  .search { width: 200px; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }
