/* ────────────────────────────────────────────────────────────────────────
   Showrunner — App Shell
   ────────────────────────────────────────────────────────────────────────
   Sidebar + topbar + main page layout. Linear-style:
   - Sidebar runs full viewport height, sits on surface-1 (slightly raised
     from canvas so it reads as chrome, not content).
   - Topbar is sticky inside main, height var(--topbar-height).
   - Page content scrolls inside main.
   ──────────────────────────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text-1);
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-sticky);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.sidebar-brand:hover { background: var(--surface-3); }

.sidebar-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-extra);
  color: white;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
  letter-spacing: var(--tracking-tight);
  color: var(--text-1);
}
.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: var(--text-4);
  margin-top: 1px;
}

.sidebar-search {
  margin: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--text-3);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.sidebar-search:hover { border-color: var(--border-strong); color: var(--text-2); }
.sidebar-search-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px var(--space-1);
  background: var(--surface-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-4);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0 var(--space-6);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.sidebar-section {
  padding: var(--space-3) var(--space-3) var(--space-1);
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-4);
  padding: 0 var(--space-2) var(--space-1);
}

.sidebar-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
  cursor: pointer;
  position: relative;
  text-align: left;
}
.sidebar-item:hover {
  background: var(--surface-3);
  color: var(--text-1);
}
.sidebar-item[aria-current="page"] {
  background: var(--surface-3);
  color: var(--text-1);
}
.sidebar-item[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--brand-500);
  border-radius: 2px;
}

.sidebar-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-item:hover .sidebar-item-icon,
.sidebar-item[aria-current="page"] .sidebar-item-icon { color: var(--text-1); }

.sidebar-item-label { flex: 1; }
.sidebar-item-badge {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  background: var(--surface-4);
  color: var(--text-3);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sidebar-item-badge[data-tone="brand"] { background: var(--brand-500); color: white; }
.sidebar-item-badge[data-tone="warn"]  { background: var(--warning-500); color: var(--text-inverse); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex-shrink: 0;
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}
.sidebar-account:hover { background: var(--surface-3); }
.sidebar-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--brand-700);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}
.sidebar-account-name {
  font-size: var(--text-sm);
  color: var(--text-1);
  font-weight: var(--weight-medium);
  line-height: 1.2;
}
.sidebar-account-sub {
  font-size: 10px;
  color: var(--text-4);
}

/* ── Main column ──────────────────────────────────────────────────────── */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;   /* allow children to shrink below content width */
  min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────────────────── */
.app-topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: rgba(10, 10, 10, 0.7);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-sticky);
}
[data-theme="light"] .app-topbar { background: rgba(250, 250, 250, 0.75); }

.topbar-menu {
  display: none;   /* mobile-only — shown via media query below */
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  border-radius: var(--radius-md);
  margin-right: var(--space-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}
.topbar-menu:hover { background: var(--surface-3); color: var(--text-1); }
.topbar-menu svg { width: 20px; height: 20px; }

.topbar-title-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.topbar-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-1);
  letter-spacing: var(--tracking-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub {
  font-size: var(--text-xs);
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ── Page content ─────────────────────────────────────────────────────── */
.app-page {
  flex: 1;
  padding: var(--space-6) var(--space-6) var(--space-12);
  max-width: var(--container-max);
  width: 100%;
}

.page-section {
  margin-bottom: var(--space-8);
}
.page-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.page-section-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
}
.page-section-sub {
  font-size: var(--text-sm);
  color: var(--text-3);
}

/* ── Auth shell (pre-login screens) ───────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(234, 88, 12, 0.16), transparent 60%),
    radial-gradient(800px 400px at 80% 110%, rgba(251, 146, 60, 0.10), transparent 65%),
    var(--canvas);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-6);
}
.auth-wordmark {
  display: block;
  width: 200px;
  height: auto;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}
/* Legacy classes — kept so old refs don't break */
.auth-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-extra);
  color: white;
  font-size: var(--text-base);
}
.auth-brand-name {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
}

.auth-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-2);
}
.auth-sub {
  color: var(--text-3);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-actions {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.auth-foot {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-3);
  text-align: center;
}
.auth-foot a { color: var(--brand-600); font-weight: var(--weight-semibold); }
.auth-foot a:hover { color: var(--brand-500); text-decoration: underline; }
[data-theme="dark"] .auth-foot a       { color: var(--brand-400); }
[data-theme="dark"] .auth-foot a:hover { color: var(--brand-300); }

.auth-tagline {
  text-align: center;
  margin-top: var(--space-6);
  font-size: var(--text-xs);
  color: var(--text-4);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .app-sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease-standard);
    z-index: var(--z-modal);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar[data-open="true"] { transform: translateX(0); }
  .app-page { padding: var(--space-4); }
  .topbar-menu { display: inline-flex; }
  .sidebar-scrim {
    position: fixed;
    inset: 0;
    background: var(--surface-overlay);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-base) var(--ease-standard);
  }
  .sidebar-scrim[data-visible="true"] {
    opacity: 1;
    pointer-events: auto;
  }
}
