/* ============================================================================
 * Shared visual design system — "modern dark sidebar" look, introduced 1.8.0.
 * Loaded by every page via <link rel="stylesheet" href="/css/design-system.css">.
 *
 * Scope: this file owns fixed PLATFORM CHROME — the sidebar shell, page
 * background, card chrome, semantic status colors (success/warning/danger),
 * and the metric pill badges. It deliberately does NOT touch --color-primary
 * / --color-secondary — those stay per-org themeable via the Theme Library
 * (see services/theme_catalog.py) and are set inline per-page + overridden
 * at runtime by applyThemeColors() in js/api.js. Mixing the two systems in
 * one file would make it unclear which colors an org admin can actually
 * change; keeping platform chrome here and brand colors in :root keeps that
 * boundary visible in the code, not just in your head.
 * ==========================================================================*/

/* --- Fonts -------------------------------------------------------------
 * --font-heading/--font-body/--font-sidebar are set at runtime by
 * applyAppearance() (js/api.js) from the platform admin's typography
 * settings (Platform Console → Appearance). Falls back to Open Sans if
 * nothing has been customized. Headings and the sidebar fall back to the
 * body font specifically (not straight to Open Sans) so setting only the
 * body font still gives a consistent look everywhere else. */
body {
  font-family: var(--font-body, "Open Sans"), sans-serif;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading, var(--font-body, "Open Sans")), sans-serif;
}
.sidebar-shell {
  font-family: var(--font-sidebar, var(--font-body, "Open Sans")), sans-serif;
}

/* --- Page background: light neutral canvas + selectable pattern -----------
 * --page-bg and the pattern class are set at runtime by applyAppearance()
 * in js/api.js, from the platform admin's appearance settings (Platform
 * Console only — see services/appearance.py). Falls back to the built-in
 * look (grid pattern, #f8fafc) if nothing has been customized. */
body.bg-background {
  background-color: var(--page-bg, #f8fafc);
}
body.bg-pattern-grid {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}
body.bg-pattern-dots {
  background-image: radial-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  background-size: 18px 18px;
}
body.bg-pattern-none {
  background-image: none;
}

/* --- Sidebar shell ---------------------------------------------------------
 * Applied to the <aside id="sidebarMount"> element itself (see sidebar.js
 * and each shell page's <aside> tag). --sidebar-from/--sidebar-to are set at
 * runtime by applyAppearance() from the platform admin's appearance
 * settings; the hardcoded values here are just the pre-JS/unconfigured
 * fallback so there's no flash before the request resolves. */
.sidebar-shell {
  background: linear-gradient(180deg, var(--sidebar-from, #2b3a4a) 0%, var(--sidebar-to, #1f2937) 100%);
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.08);
}

/* --- Sidebar nav items ------------------------------------------------------
 * Base state lives here; active/hover state is toggled by sidebar.js adding
 * .nav-item-active (bright accent text + left bar) instead of the old
 * bg-primary-fixed/text-primary utility combo, which assumed a light shell. */
.sidebar-shell .nav-item {
  color: #9ca3af;
  position: relative;
  border-left: 3px solid transparent;
}
.sidebar-shell .nav-item:hover {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.05);
}
.sidebar-shell .nav-item.nav-item-active {
  color: var(--color-primary, #3b82f6);
  background: rgba(59, 130, 246, 0.08);
  border-left-color: var(--color-primary, #3b82f6);
}
.sidebar-shell .nav-section-label {
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sidebar-shell .sidebar-divider {
  border-color: rgba(255, 255, 255, 0.08);
}
/* User/profile row text needs to read on the dark gradient too. */
.sidebar-shell #userName { color: #f1f5f9; }
.sidebar-shell #userRole,
.sidebar-shell #appVersionTag { color: #9ca3af; }
.sidebar-shell a[title="My Account"]:hover { opacity: 0.85; }
.sidebar-shell button[title="Sign out"] { color: #9ca3af; }
.sidebar-shell button[title="Sign out"]:hover { color: #ef4444; }

/* --- Content cards ----------------------------------------------------------
 * Replaces the old `bg-surface-container-lowest rounded-2xl shadow-sm` combo.
 * Use class="card" going forward; rounded-2xl (16px) is swapped for 8-12px
 * per spec, and the shadow is a flatter, more modern elevation. */
.card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

/* --- Settings tabs (Admin Console / Platform Console) ---------------------- */
/* --- Settings tabs (Admin Console / Platform Console) ---------------------- */
/* Deliberately a separate class from Tailwind's .hidden: sections like
 * #reviewSection/#ssoSection are ALSO hidden/shown by their own independent
 * logic (pending reviews exist? role permits SSO?). An element must stay
 * hidden if EITHER condition says hide — using one shared class would let
 * showTab() clobber that logic (e.g. reveal SSO settings on the wrong role
 * just because its tab is active). Two separate display:none rules compose
 * with AND semantics for free, no JS coordination needed. */
.tab-hidden {
  display: none;
}
.tab-btn {
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover {
  color: #1e293b;
}
.tab-btn.tab-btn-active {
  color: var(--color-primary, #3b82f6);
  border-bottom-color: var(--color-primary, #3b82f6);
}

/* --- Metric pill badges ------------------------------------------------------
 * Semantic status colors — deliberately NOT tied to --color-primary/secondary,
 * same reasoning as the existing error/error-container tokens: an org
 * shouldn't be able to make "positive" read as anything but positive. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill-positive { background: #d1fae5; color: #065f46; }
.pill-negative { background: #fee2e2; color: #991b1b; }
.pill-neutral  { background: #fef3c7; color: #92400e; }
.pill-info     { background: #dbeafe; color: #1e40af; }
