/*
 * apps/support — 2026 dark-admin-console redesign (27 Sep 2026).
 *
 * REPLACES T-884's cream/gold/red styling entirely, per Mahdi's explicit
 * direction (docs/figma-prompt-apps-support.md): this internal tool gets
 * its own distinct visual identity, separate from the member-facing
 * brand — no cream, gold or red as primary colors here. Dark sidebar +
 * light content, modern geometric-leaning sans, thin 1px borders + soft
 * low-opacity shadows over heavy drop-shadows, modest 6-10px radii.
 * Structure picked from 3 real built comparisons (docs/helper-inbox.md
 * I-8005) — this is "Variant C": KPI cards + a "Needs attention"
 * highlights rail, breakdown tables full-width below.
 *
 * Accent color, D-85 (27 Sep 2026): originally shipped with a one-off
 * indigo (#4f46e5) as this app's own distinct accent. Retired same day
 * in favor of the shared navy/gold pair (#1B4F82/#C9A227) already proven
 * in apps/console + apps/web, so all three apps read as one brand.
 *
 * Served via the same `GET /styles.css` static route T-884 added — see
 * that route's own comment in server.mjs, unchanged by this task.
 *
 * FONT NOTE, same constraint as T-884: the CSP here is `default-src
 * 'none'` with no `font-src` at all, so Inter/Geist cannot be fetched
 * externally without a CSP change this visual-only task doesn't own.
 * Falls back to the most geometric/grotesk-leaning system stack
 * available (Segoe UI / SF Pro / system-ui) — documented as a deliberate
 * choice, easy to revisit as its own separately-reviewed change if
 * self-hosting a real webfont is wanted later.
 */

:root {
  /* Dark sidebar/chrome */
  --chrome: #0b0e14;
  --chrome-raised: #171b24;
  --chrome-border: #232838;
  --chrome-text: #e6e8ec;
  --chrome-text-dim: #8b93a3;

  /* Light content surface */
  --surface: #f7f8fa;
  --card: #ffffff;
  --border: #e4e7ec;
  --ink: #14181f;
  --ink-secondary: #5b6472;

  /* One confident accent — navy/gold, D-85 (27 Sep 2026): apps/support's
     indigo retired in favor of the shared navy/gold pair already proven
     in apps/console + apps/web (primary #1B4F82/hover #123A61/dark
     #0E2C4A, accent gold #C9A227). --accent-soft is a ~10% navy tint on
     white, same derivation this file already used for the indigo soft
     tone it replaces. */
  --accent: #1b4f82;
  --accent-hover: #123a61;
  --accent-soft: #e8edf3;

  /* Status badges */
  --success: #059669;
  --success-soft: #e7f6ef;
  --warning: #b45309;
  --warning-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --neutral: #5b6472;
  --neutral-soft: #eef1f4;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 2px rgba(20, 24, 31, 0.04), 0 1px 6px rgba(20, 24, 31, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--surface);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

.accent {
  color: var(--accent);
}

/* Visible focus everywhere — daily-use internal tool, keyboard nav matters. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   App shell — fixed dark sidebar + light content area
   --------------------------------------------------------------------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--chrome);
  color: var(--chrome-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Mobile-only toggle — hidden entirely on desktop widths (no checkbox/
   label visible, no behavior change at all above the breakpoint). */
.nav-toggle-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Real, confirmed gap caught live: the checkbox itself is invisible
   (opacity: 0), so its own default focus ring renders somewhere a
   keyboard user can never see. Style the visible label instead when the
   checkbox it controls has keyboard focus, so Tab still shows something
   real. */
.nav-toggle-checkbox:focus-visible ~ .sidebar .nav-toggle-label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-toggle-label {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  padding: 0 10px 4px;
}

.sidebar-logo {
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar-tag {
  font-size: 11px;
  color: var(--chrome-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 10px 20px;
  border-bottom: 1px solid var(--chrome-border);
  margin-bottom: 16px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--chrome-text-dim);
  font-weight: 500;
  font-size: 13.5px;
}

.sidebar-link:hover {
  background: var(--chrome-raised);
  color: var(--chrome-text);
}

.sidebar-link[aria-current="page"] {
  background: var(--accent);
  color: #ffffff;
}

.sidebar-link .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  flex-shrink: 0;
}

.sidebar-link[aria-current="page"] .dot {
  opacity: 1;
}

.sidebar-session {
  border-top: 1px solid var(--chrome-border);
  padding-top: 14px;
  margin-top: 8px;
}

.sidebar-session-user {
  font-size: 13px;
  color: var(--chrome-text);
  padding: 0 10px 8px;
  overflow-wrap: anywhere;
}

.sidebar-signout-button {
  width: 100%;
  background: var(--chrome-raised);
  border: 1px solid var(--chrome-border);
  color: var(--chrome-text-dim);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.sidebar-signout-button:hover {
  color: var(--chrome-text);
  border-color: #2a3040;
}

.content {
  flex: 1;
  min-width: 0;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page {
  padding: 28px 32px 56px;
  max-width: 1200px;
}

/* The topbar already shows the page title visibly — this `<h1>` still
   exists in every view (real heading structure/landmark for screen
   readers), just visually hidden rather than `display: none` (which
   would remove it from the accessibility tree too, not only the page). */
.page-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-meta {
  color: var(--ink-secondary);
  font-size: 13.5px;
  margin: 0 0 20px;
}

/* ---------------------------------------------------------------------
   Shared components
   --------------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--ink-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #fbfbfc;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fafbfc;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-neutral {
  background: var(--neutral-soft);
  color: var(--neutral);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.empty {
  color: var(--ink-secondary);
  font-style: italic;
  padding: 24px 0;
  text-align: center;
}

.alert {
  background: var(--danger-soft);
  border: 1px solid #f3b5ae;
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------------
   Overview screen — Variant C: KPI cards + attention rail, breakdowns
   full-width below
   --------------------------------------------------------------------- */

.overview-top {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  margin-bottom: 28px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-secondary);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.attention-rail {
  padding: 16px 18px;
}

.attention-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.attention-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .overview-top,
  .breakdown-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------------
   Mobile responsiveness round (27 Sep 2026) — the fixed 240px sidebar
   was confirmed live to eat close to half a 375px phone screen, leaving
   an unreadably narrow content column. Below this breakpoint the
   sidebar collapses to a compact top bar; nav/session hide behind the
   checkbox-hack toggle (see layout.mjs's own header for why this is
   pure CSS, no JavaScript).
   --------------------------------------------------------------------- */
.table-scroll-hint {
  display: none;
}

@media (max-width: 768px) {
  .shell {
    flex-direction: column;
    min-height: 0;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 12px 16px;
  }

  .sidebar-brand {
    padding: 0;
  }

  .nav-toggle-label {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
  }

  .nav-toggle-label:hover {
    background: var(--chrome-raised);
  }

  .hamburger-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--chrome-text);
    border-radius: 1px;
  }

  /* Collapsed by default on mobile — revealed by :checked below. Real
     transition (not an abrupt display swap) so the toggle reads as
     intentional, not a layout glitch. */
  .sidebar-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
  }

  .nav-toggle-checkbox:checked ~ .sidebar .sidebar-collapsible {
    max-height: 70vh;
    overflow-y: auto;
    margin-top: 12px;
  }

  .sidebar-tag {
    padding: 0 0 12px;
    margin-bottom: 12px;
  }

  .sidebar-session {
    margin-top: 12px;
  }

  .content {
    min-width: 0;
  }

  .page {
    padding: 20px 16px 40px;
  }

  .topbar {
    padding: 14px 16px;
  }

  /* Data tables — same "confirmed live, not assumed" finding: shrinking
     6-column tables to fit a phone makes every cell unreadable. Scroll
     horizontally instead, with a real (not decorative-only) text hint
     above each table-scroll container so the affordance doesn't depend
     on a visual scrollbar a touch device may not even show. */
  .table-scroll-hint {
    display: block;
    font-size: 11px;
    color: var(--ink-secondary);
    margin: 0 0 8px;
  }

  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-scroll table {
    min-width: 480px;
  }
}

/* ---------------------------------------------------------------------
   Login screen — D-77 round: lighter, centered card on a light/neutral
   background (was a full near-black canvas — Mahdi's own "too heavy"
   feedback). Same light `--surface` the content area already uses,
   matching real modern SaaS sign-in patterns rather than a dark canvas.
   --------------------------------------------------------------------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--surface);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 36px 36px 32px;
  width: 100%;
  max-width: 400px;
}

.login-brand {
  text-align: center;
  margin-bottom: 22px;
}

.login-logo {
  display: block;
  margin: 0 auto 10px;
  border-radius: 8px;
}

.login-brand-name {
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}

.login-heading {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 18px;
  text-align: center;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
  margin-bottom: 6px;
}

.field-hint {
  font-weight: 400;
  color: var(--ink-secondary);
  font-size: 11.5px;
  display: block;
  margin-top: 2px;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--card);
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

.button-primary {
  width: 100%;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 2px;
}

.button-primary:hover {
  background: var(--accent-hover);
}
