/* Shared page shell: topbar, section nav, main container, page header,
   empty state, and modal - used by every authenticated page (members,
   commands, execute, warnings, cool). Page-specific content styles live in
   their own stylesheet alongside this one. */

/* Three-track grid (spacer / brand / account) so the brand block sits
   truly centered in the bar regardless of how wide the account block is,
   rather than just being pushed left by justify-content: space-between. */
:root { --topbar-height: 60px; }

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.brand { font-weight: 700; font-size: 19px; }
.topbar-right {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
}
.whoami { color: var(--text-muted); font-size: 13px; }

/* Row below the topbar: nav (sidebar) + the page's own <main>, wrapped
   together by renderShell(). Under dir="rtl" the first flex child (nav)
   lands at the visual right edge - a right-hand sidebar with no extra
   positioning tricks needed. */
.shell-body {
  display: flex;
  align-items: flex-start;
}

/* --- Section nav: one link per page, stacked top-to-bottom in the
   alphabetical order NAV_SECTIONS is already sorted in, each carrying its
   destination page's accent color as a left-border indicator. --- */
.section-nav {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 6px;
  width: 220px;
  padding: 16px 12px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Bordered pill buttons, now full-width rows. Colors/hover states are
   final; the border is left as a plain 1px line deliberately - the user is
   sourcing a hover/active animation treatment to apply on top of this later. */
.nav-link {
  --nav-color: var(--accent-members);
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-deep);
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease;
}
.nav-link .nav-icon { font-size: 15px; line-height: 1; }
.nav-link:hover {
  color: var(--text);
  border-color: var(--nav-color);
  text-decoration: none;
}
.nav-link.active {
  color: var(--text);
  border-color: var(--nav-color);
  background: color-mix(in srgb, var(--nav-color) 14%, transparent);
}

.main {
  flex: 1;
  min-width: 0;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}
.main.wide { max-width: 1180px; }

.page-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.page-header h1 {
  font-size: 32px;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-header .page-logo {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--page-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--page-color) 16%, transparent);
}
.page-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop.show { display: flex; }
.modal {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal-target {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 18px;
}
.modal-target strong { color: var(--text); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.field-row { margin-bottom: 12px; }

/* Stat tiles - shared by any page with headline numbers up top (warnings,
   stats, auditlog). Default accent below; each page's own stylesheet
   (loaded after this one) overrides .stat-value's color to its accent. */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card { padding: 18px 20px; }
.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent-members);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* Below this width there's no room for a permanent 220px sidebar - fall
   back to the old horizontal scrolling pill row, stacked above the content. */
@media (max-width: 860px) {
  .shell-body { flex-direction: column; }
  .section-nav {
    flex-direction: row;
    width: auto;
    height: auto;
    position: static;
    overflow-x: auto;
    overflow-y: visible;
    border-left: none;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  .section-nav::-webkit-scrollbar { display: none; }
  .nav-link { border-radius: 999px; }
}

@media (max-width: 560px) {
  .main { padding: 16px; }
  .section-nav { padding: 10px 8px; }
}
