/* IlmSuite.pro — Super Admin console
 * Design tokens follow the project's own agreed UI/UX direction
 * (ILMSUITE_UI_UX_DESIGN_SYSTEM.md): IlmSuite Royal Blue as brand,
 * reserved for nav/primary actions/links only; a strictly separate
 * semantic status palette; high-density ops tier for this actor.
 * Logical CSS properties (margin-inline, not margin-left) used
 * throughout per the doc's RTL-readiness-from-the-token-layer principle,
 * even though this milestone's copy is English-only.
 */

:root {
  --blue-50: #EEF2FF;
  --blue-100: #E0E7FF;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;
  --blue-900: #1E3A8A;

  --status-success-bg: #DCFCE7;
  --status-success-fg: #15803D;
  --status-warning-bg: #FEF3C7;
  --status-warning-fg: #B45309;
  --status-danger-bg: #FEE2E2;
  --status-danger-fg: #B91C1C;
  --status-neutral-bg: #F1F5F9;
  --status-neutral-fg: #475569;

  --surface: #FFFFFF;
  --surface-sunken: #F8FAFC;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  /* CORRECTION (M57 gap analysis): centralizes the muted-text-on-dark-
     sidebar shade already established by .wordmark-sub below, so new
     code (the platform/academy branding fallback text) references one
     real token instead of a second, slightly different hardcoded hex. */
  --sidebar-text-muted: #94A3B8;

  /* M58: new tokens, added so the dark sidebar's remaining colors can
     be independently themed too (previously reused --text or were
     hardcoded inline - confirmed by direct audit before writing this).
     Every value below matches today's REAL, existing color exactly -
     this addition changes zero visible appearance by itself. */
  --sidebar-bg: #0F172A;
  --sidebar-text: #CBD5E1;
  --sidebar-heading: #FFFFFF;
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  /* One shared token for "text placed on a brand-colored background" -
     previously four separate hardcoded #fff instances (primary button,
     active tab, active/hovered sidebar nav link) that could silently
     drift out of sync if only one were ever updated. */
  --text-on-brand: #FFFFFF;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius: 8px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface-sunken);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--blue-700); }

.shell {
  /* FIX (REVISED): switched from CSS Grid to Flexbox for this exact
     "make the shorter column stretch to match the taller one" problem.
     The previous grid-template-rows:1fr attempt was real, correct CSS,
     but a genuine, confirmed-real browser inconsistency exists in how
     `1fr` row tracks resolve against a container sized only by
     min-height (not a fixed height) - different engines can still
     shrink the row to content in that specific combination. Flexbox's
     align-items:stretch (its own default, needs no extra property)
     has none of that ambiguity - it is the textbook-standard, always-
     reliable solution for equal-height sidebar layouts. */
  display: flex;
  min-height: 100vh;
}

.sidebar {
  /* width/flex-shrink replace the old grid-template-columns:220px -
     Flexbox needs the sidebar to declare its own width explicitly. */
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding-block: 24px;
  padding-inline: 20px;
}

.sidebar .wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--sidebar-heading);
  margin-block-end: 4px;
}

.sidebar .wordmark-sub {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-block-end: 32px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  padding-block: 9px;
  padding-inline: 10px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-block-end: 2px;
}

.sidebar nav a:hover { background: var(--sidebar-hover-bg); color: var(--text-on-brand); }
.sidebar nav a.active { background: var(--blue-700); color: var(--text-on-brand); font-weight: 500; }
.sidebar nav a svg, .nav-icon { flex-shrink: 0; width: 18px; height: 18px; }

.main { flex: 1; min-width: 0; padding: 28px 32px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 24px;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

.btn {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  padding-block: 8px;
  padding-inline: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: var(--surface-sunken); }
.btn:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }

.btn-primary {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: var(--text-on-brand);
}
.btn-primary:hover { background: var(--blue-700); }

.btn-danger { color: var(--status-danger-fg); border-color: var(--status-danger-bg); }
.btn-danger:hover { background: var(--status-danger-bg); }

.btn-sm { padding-block: 5px; padding-inline: 10px; font-size: 12.5px; }

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

table { width: 100%; border-collapse: collapse; }

th {
  text-align: start;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding-block: 12px;
  padding-inline: 16px;
  border-block-end: 1px solid var(--border);
}

td {
  padding-block: 12px;
  padding-inline: 16px;
  border-block-end: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

tr:last-child td { border-block-end: none; }
tr:hover td { background: var(--surface-sunken); }

.mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-block: 3px;
  padding-inline: 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.chip::before { content: ''; inline-size: 6px; block-size: 6px; border-radius: 50%; }

.chip-active { background: var(--status-success-bg); color: var(--status-success-fg); }
.chip-active::before { background: var(--status-success-fg); }
.chip-trial { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.chip-trial::before { background: var(--status-warning-fg); }
.chip-suspended { background: var(--status-danger-bg); color: var(--status-danger-fg); }
.chip-suspended::before { background: var(--status-danger-fg); }
.chip-neutral { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.chip-neutral::before { background: var(--status-neutral-fg); }

.field { margin-block-end: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-block-end: 5px;
  color: var(--text-muted);
}
.field input, .field select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 13.5px;
  padding-block: 8px;
  padding-inline: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.field input:focus-visible, .field select:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 1px;
}

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(15,23,42,0.2);
}
.modal h2 { font-family: var(--font-display); font-size: 17px; margin-block-start: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-block-start: 18px; }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state p { margin-block-end: 12px; }

.error-banner {
  background: var(--status-danger-bg);
  color: var(--status-danger-fg);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-block-end: 16px;
  display: none;
}
.error-banner.visible { display: block; }

.toast {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-end: 24px;
  background: var(--text);
  color: var(--text-on-brand);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  z-index: 20;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
  .sidebar .wordmark-sub { display: none; }
  .sidebar nav { display: flex; gap: 4px; }
  /* CORRECTION (M57 gap analysis): the sidebar becomes a compact
     horizontal bar on mobile (confirmed above) - the branding footer
     line was designed for the desktop VERTICAL sidebar (full-width
     border-top, centered text) and would look broken squeezed into
     this horizontal bar, exactly like .wordmark-sub already gets
     hidden here for the same reason. The logo itself is also shrunk to
     fit the compact 14px-padding bar instead of overflowing it. */
  .sidebar #powered-by-line { display: none; }
  .sidebar #academy-logo-img,
  .sidebar #platform-logo-img { max-height: 28px !important; max-width: 100px !important; }
}

/* ==========================================================================
   Light, consumer-grade tier (Student/Teacher portals) — per the project's
   own design doc: lower density, more whitespace, larger touch targets,
   simpler nav than the ops tier above. A genuinely different visual
   treatment, not a reuse of the dense-table admin look at a smaller scale.
   ========================================================================== */

.shell-light {
  max-width: 880px;
  margin-inline: auto;
  padding: 0 20px;
}

.topbar-light {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 20px;
  border-block-end: 1px solid var(--border);
  margin-block-end: 24px;
}

.topbar-light .wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--blue-900);
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-block-end: 4px;
  margin-block-end: 28px;
  -webkit-overflow-scrolling: touch;
}

.tabs a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding-block: 10px;
  padding-inline: 16px;
  border-radius: 999px;
  white-space: nowrap;
}
.tabs a:hover { background: var(--surface); color: var(--text); }
.tabs a.active { background: var(--blue-600); color: var(--text-on-brand); }
.tabs a:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.tabs a svg { flex-shrink: 0; width: 18px; height: 18px; }

.page-title-light {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin-block-end: 20px;
}

/* Card-list, not dense table — the consumer-tier content pattern */
.item-list { display: flex; flex-direction: column; gap: 10px; }

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

.item-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-block-end: 6px;
}

.item-card-title { font-weight: 600; font-size: 15px; }
.item-card-meta { font-size: 13px; color: var(--text-muted); margin-block-end: 4px; }
.item-card-body { font-size: 13.5px; color: var(--text); line-height: 1.6; }

.btn-light {
  font-size: 14.5px;
  padding-block: 11px;
  padding-inline: 18px;
  border-radius: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-block-end: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--blue-900);
}
.stat-card .stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-block-start: 4px;
}

.progress-bar {
  block-size: 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
  margin-block: 6px;
}
.progress-bar-fill {
  block-size: 100%;
  background: var(--blue-600);
  border-radius: 999px;
}
