/* Shared styles for the frontend pages: CSS vars, page scaffolding, and the
   app-shell chrome (fixed top bar + fixed left sidebar, content scrolls) —
   adapted from the bubble repo's css/shell.css, simplified: no auth chrome,
   no per-page nav sections. Load before the page's own <style> block so
   pages can override. Page-specific styles (table, search) stay inline. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --row-hover: #f3f4f6;
  --card: #f9fafb;
  --accent: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --topbar-h: 56px;
  --sidebar-w: 220px;
  --nav-bg: rgba(255, 255, 255, 0.92);
  /* the top-bar wash behind the wordmark — bubble's --brand-wash pattern
     (eased alpha fades so the tails vanish) in glitcj colors: glitch
     green → violet. Theme-independent by design — the wash is the surface. */
  --brand-wash: linear-gradient(90deg,
    #3ddc8400 0%,
    #3ddc840d 7%,
    #3ddc8426 13%,
    #3ddc844d 19%,
    #3ddc8480 25%,
    #3ddc84b3 31%,
    #3ddc84d9 38%,
    #7367f0d9 62%,
    #7367f0b3 69%,
    #7367f080 75%,
    #7367f04d 81%,
    #7367f026 87%,
    #7367f00d 93%,
    #7367f000 100%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --border: #262a33;
    --row-hover: #1a1d24;
    --card: #171a21;
    --accent: #60a5fa;
    --danger: #f87171;
    --ok: #4ade80;
    --warn: #fbbf24;
    --nav-bg: rgba(15, 17, 21, 0.92);
  }
}
/* inline Lucide icons (glitcjIcon() in js/shell.js) — em-sized so they
   track the row's font size */
.icon-svg {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* ── Top bar — markup injected by js/shell.js ─────────────────────────── */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
}
/* the wash spans the whole bar, painted on the BAR itself (::before), not
   on the brand link — click-transparent and behind the bar's children
   (bubble's shell pattern) */
#topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--brand-wash);
  pointer-events: none;
  z-index: 0;
}
.topbar-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--fg);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 1;
}
.topbar-menu:hover { background: var(--row-hover); }
/* wordmark centered in the bar — absolute so the hamburger can't push it.
   White with an 8-direction 1px black outline over the wash, the bubble
   wordmark treatment. */
.nav-brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  text-decoration: none;
}
.nav-brand .brand-box {
  display: inline-flex;
  align-items: center;
  height: var(--topbar-h);
  padding: 0 0.42rem;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-shadow:
    -1px -1px 0 #000, 0 -1px 0 #000, 1px -1px 0 #000,
    -1px  0   0 #000,                1px  0   0 #000,
    -1px  1px 0 #000, 0  1px 0 #000, 1px  1px 0 #000;
}

/* ── Sidebar — markup injected by js/shell.js ─────────────────────────── */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 110;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem 1.5rem;
  /* solid sidebar; the content divider is a background layer — a 1px line
     inset 14px from top and bottom so it never reads as a full wall */
  background:
    linear-gradient(var(--border), var(--border)) right 0 top 14px / 1px calc(100% - 28px) no-repeat,
    var(--card);
  transition: transform 0.15s ease, visibility 0.15s;
}
body.sidebar-collapsed #sidebar {
  transform: translateX(-100%);
  visibility: hidden;
}
.sidebar-heading {
  padding: 0 0.75rem 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* view buttons — <button>s, not links (they filter the one page), but
   styled exactly like bubble's sidebar nav rows: icon + label, accent
   highlight on the active one */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--fg);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.sidebar-link:hover { background: var(--row-hover); }
.sidebar-link-icon {
  display: inline-flex;
  align-items: center;
  font-size: 0.95rem;
}
.sidebar-link.active {
  background: rgba(37, 99, 235, 0.10);
  color: var(--accent);
  font-weight: 600;
}

/* ── Content ──────────────────────────────────────────────────────────── */
main {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 1.25rem) 1.5rem 4rem;
  transition: margin-left 0.15s ease;
}
body.sidebar-collapsed main { margin-left: 0; }
.page {
  max-width: 900px;
  margin: 0 auto;
}
h1 {
  font-size: 1.375rem;
  margin: 0 0 0.25rem;
}
.subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 1.5rem;
}
#status {
  color: var(--muted);
  font-size: 0.875rem;
  padding: 1rem 0;
}
#status.error {
  color: var(--danger);
  white-space: pre-wrap;
}
footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.75rem;
}

/* ── Mobile: the sidebar becomes an off-canvas drawer over the content ── */
@media (max-width: 900px) {
  main,
  body.sidebar-collapsed main { margin-left: 0; }
  #sidebar {
    z-index: 130;
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: 0 0 30px rgba(20, 38, 58, 0.25);
  }
  /* the drawer ignores the desktop collapse state — open wins */
  body.sidebar-open #sidebar,
  body.sidebar-collapsed.sidebar-open #sidebar {
    transform: none;
    visibility: visible;
  }
  #shell-scrim {
    position: fixed;
    inset: 0;
    z-index: 125;
    background: rgba(20, 38, 58, 0.4);
  }
}
