/* ============================================================
   SJ88 Online Domain Manager — Pastel UI Shared Stylesheet
   Single file shared across every page.
   THEME-AWARE via CSS variables — toggled by `body.theme-dark`.
   ============================================================ */

:root {
  /* === Brand pastels (brand identity, constant across themes) === */
  --peach: #FFE5D9;
  --peach-deep: #FFCAB4;
  --mint: #D4F0E8;
  --mint-deep: #A9E0CF;
  --lavender: #E8DEF8;
  --lavender-deep: #C9B8EE;

  /* === Light-theme surfaces (default) === */
  --cream: #FFF8F0;
  --ink: #4A4458;
  --muted: #8B85A0;
  --line: #ECE6F0;

  /* === Decorative pastels (used in alerts / accents) === */
  --danger: #F4B5B5;
  --warn: #FCE4B5;
  --success: #BCE7CF;

  /* === Surface tokens (used by cards, kpi, table, modal, inputs) === */
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-soft: var(--cream);
  --surface-overlay: rgba(15, 18, 40, 0.55);

  /* === Error / accent tones === */
  --err-ink: #b42318;
  --err-soft: rgba(180, 35, 24, 0.10);
  --warn-border: #f3d28b;
  --secret-bg: #fff8f0;

  /* === Secondary button hover (admin.html) === */
  --btn-secondary-hover: #d6c5a8;

  /* === Pill-toggle shadow (admin-logs.html) === */
  --shadow-pill: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 18px 50px rgba(74, 68, 88, 0.18);
  --shadow-kpi: 0 1px 3px rgba(74, 68, 88, 0.06);
  --hover-row-bg: rgba(252, 231, 243, 0.35);

  /* === Radii / motion (constant) === */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-sm: 0 4px 14px rgba(74, 68, 88, 0.06);
  --shadow-md: 0 10px 30px rgba(74, 68, 88, 0.08);
  --shadow-lg: 0 18px 50px rgba(74, 68, 88, 0.12);

  --t-fast: 160ms ease;
  --t-mid: 280ms ease;

  color-scheme: light;
}

/* === Dark theme overrides — swap surfaces, keep brand pastels ===
   The dual selector (`body.theme-dark, html.theme-dark body`) lets the
   pre-paint <head> script tag html with .theme-dark (since <body> doesn't
   exist yet) while normal toggling still happens on <body>. Both apply the
   same set of CSS-var overrides — they're are scoped to whichever element
   carries the flag via the descendant selector. */
body.theme-dark,
html.theme-dark body {
  /* In dark mode, brand-pastels are darkened so they read as accent chips */
  --peach: #5a3a2e;
  --peach-deep: #8a5544;
  --mint: #1f3a35;
  --mint-deep: #3a6a5e;
  --lavender: #3a2f55;
  --lavender-deep: #6a55a8;

  --cream: #15151f;
  --ink: #ECE6F0;
  --muted: #9b95b3;
  --line: #2c2c3f;

  --danger: #5a2a2a;
  --warn: #5a4622;
  --success: #2a4a37;

  --surface: #1d1d2c;
  --surface-2: #25253a;
  --surface-soft: #1a1a26;
  --surface-overlay: rgba(0, 0, 0, 0.65);

  --err-ink: #ff8080;
  --err-soft: rgba(255, 128, 128, 0.16);
  --warn-border: #7a5828;
  --secret-bg: #2a2218;

  --btn-secondary-hover: #3a3658;

  --shadow-pill: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-modal: 0 18px 50px rgba(0, 0, 0, 0.55);
  --shadow-kpi: 0 1px 3px rgba(0, 0, 0, 0.35);
  --hover-row-bg: rgba(106, 85, 168, 0.18);

  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t-mid), color var(--t-mid);
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 700; line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(1.8rem, 2.5vw + 1rem, 2.8rem); }
h2 { font-size: clamp(1.4rem, 1.5vw + 1rem, 2rem); }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1em; color: var(--ink); }
small, .muted { color: var(--muted); font-size: 0.875rem; }

/* ---------- Layout primitives ---------- */
.container {
  width: min(1180px, 92vw);
  margin: 0 auto;
}
.container-sm {
  width: min(720px, 92vw);
  margin: 0 auto;
}
.stack > * + * { margin-top: var(--gap, 1rem); }
.row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Navbar ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--cream) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
  gap: 1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.15rem; color: var(--ink);
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(135deg, var(--peach-deep), var(--lavender-deep));
  display: grid; place-items: center; color: white; font-weight: 800;
}
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-links a {
  padding: 8px 14px; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: 0.92rem;
  transition: var(--t-fast);
}
.nav-links a:hover { background: var(--peach); color: var(--ink); }
.nav-cta { padding: 8px 16px; border-radius: 999px;
  background: var(--ink); color: white; font-weight: 700; font-size: 0.9rem; }

/* ---------- Topbar action group (theme/lang/install buttons) ---------- */
.nav-actions { display: inline-flex; gap: 6px; align-items: center; }
.nav-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); font-size: 1.05rem;
  cursor: pointer; transition: var(--t-fast);
  padding: 0;
  text-decoration: none;
}
.nav-icon-btn:hover { background: var(--peach); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.nav-icon-btn[aria-pressed="true"] { background: var(--lavender); }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-size: 0.85rem; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 14px;
}
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { opacity: 0.6; }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px;
  font-weight: 700; font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer; transition: var(--t-fast);
  background: var(--line); color: var(--ink);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--ink); color: white; }
.btn-primary:hover { background: #352f40; }
.btn-peach { background: var(--peach-deep); color: var(--ink); }
.btn-mint  { background: var(--mint-deep);  color: var(--ink); }
.btn-danger { background: var(--danger);        color: #2d1420; }
.btn-danger:hover { background: #e89a9a; }
.btn-lav   { background: var(--lavender-deep); color: var(--ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-soft {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.card-pastel-peach   { background: var(--peach); border: 1px solid var(--peach-deep); }
.card-pastel-mint    { background: var(--mint);  border: 1px solid var(--mint-deep); }
.card-pastel-lav     { background: var(--lavender); border: 1px solid var(--lavender-deep); }

.role-card {
  position: relative;
  border-radius: var(--radius-xl);
  padding: 2rem;
  display: flex; flex-direction: column; gap: 1rem;
  border: 1px solid var(--line);
  transition: var(--t-mid);
  overflow: hidden;
}
.role-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.role-card .icon-bubble {
  width: 72px; height: 72px; border-radius: 22px;
  display: grid; place-items: center;
}
.role-card h2 { font-size: 1.6rem; }
.role-card ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.role-card li { display: flex; align-items: flex-start; gap: 10px; color: var(--ink); }
.role-card .check {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 6px;
  background: var(--mint-deep); color: var(--ink);
  display: grid; place-items: center; font-size: 0.7rem; font-weight: 800;
}

.role-card.student  { background: linear-gradient(160deg, var(--peach), var(--cream)); }
.role-card.student .icon-bubble { background: var(--peach-deep); }
.role-card.admin    { background: linear-gradient(160deg, var(--lavender), var(--cream)); }
.role-card.admin .icon-bubble   { background: var(--lavender-deep); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 0.9rem; color: var(--ink); }
.field .hint { font-size: 0.78rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font: inherit;
  color: var(--ink);
  transition: var(--t-fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--lavender-deep);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--lavender-deep) 35%, transparent);
}
.textarea { min-height: 110px; resize: vertical; }
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row .input { flex: 1; }
.suffix-chip {
  display: inline-flex; align-items: center;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--mint); color: var(--ink); font-weight: 600;
  border: 1px solid var(--mint-deep);
}
.form-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 1rem; align-items: center; justify-content: space-between;
}

/* ---------- Placeholder image ---------- */
.placeholder-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--peach), var(--lavender));
  display: grid; place-items: center;
  color: var(--ink);
  font-weight: 700;
  border: 1px solid var(--line);
}
.placeholder-img.mint { background: linear-gradient(135deg, var(--mint), var(--peach)); }
.placeholder-img.lav  { background: linear-gradient(135deg, var(--lavender), var(--mint)); }

/* ---------- Badges & tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
  background: var(--line); color: var(--ink);
}
.badge.peach { background: var(--peach); color: var(--ink); }
.badge.mint  { background: var(--mint); }
.badge.lav   { background: var(--lavender); }
.badge.warn  { background: var(--warn); }
.badge.danger { background: var(--danger); }
.badge.success { background: var(--success); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.success { background: var(--mint-deep); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }

/* ---------- Hero / Section spacing ---------- */
.section { padding: 3rem 0; }
.section-tight { padding: 1.5rem 0; }
.hero {
  padding: 4rem 0 2rem;
  text-align: center;
}
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--lavender); color: var(--ink);
  font-size: 0.8rem; font-weight: 700; margin-bottom: 1rem;
}
.hero p.lead { max-width: 640px; margin: 0 auto 1.5rem; color: var(--muted); font-size: 1.05rem; }

/* ---------- Stats ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}
.stat .num { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat .lbl { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); overflow: hidden;
}
table.data {
  width: 100%; border-collapse: collapse;
  color: var(--ink);
}
table.data th, table.data td {
  padding: 14px 16px; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
table.data thead th {
  background: var(--surface-soft);
  font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-soft); }

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex; padding: 6px; gap: 4px;
  background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: 999px;
}
.tab {
  padding: 8px 16px; border-radius: 999px;
  font-weight: 600; font-size: 0.9rem; color: var(--muted);
}
.tab.active { background: var(--ink); color: white; }

/* ---------- Stepper (visual) ---------- */
.stepper {
  display: flex; gap: 0; align-items: center;
  width: 100%;
}
.step {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
  position: relative;
}
.step .pip {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--line); color: var(--muted);
  display: grid; place-items: center; font-weight: 800;
  z-index: 2;
}
.step .lbl { font-size: 0.85rem; color: var(--muted); text-align: center; font-weight: 600; }
.step::after {
  content: ""; position: absolute;
  top: 18px; left: 50%; right: -50%; height: 3px;
  background: var(--line); z-index: 1;
}
.step:last-child::after { display: none; }
.step.active .pip { background: var(--ink); color: white; }
.step.active .lbl { color: var(--ink); }
.step.done .pip  { background: var(--mint-deep); color: var(--ink); }
.step.done::after { background: var(--mint-deep); }

/* ---------- Wizard CSS :target ---------- */
.wizard {
  display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem;
  align-items: stretch;
}
@media (max-width: 860px) { .wizard { grid-template-columns: 1fr; } }
.wizard-side {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.25rem;
}
.wizard-side ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.wizard-side a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-weight: 600; color: var(--muted);
}
.wizard-side a:hover { background: var(--surface-soft); color: var(--ink); }
.wizard-side a .num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--line); color: var(--ink);
  display: grid; place-items: center; font-size: 0.85rem; font-weight: 800;
}
.wizard-content {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 2rem;
  min-height: 360px;
}
.wizard-step { display: none; }
.wizard-step:target { display: block; }
.wizard-step:first-of-type:not(:target) { display: block; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 4rem; padding: 2rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.85rem;
}
.footer .row { justify-content: space-between; }

/* ---------- Utility ---------- */
.text-center { text-align: center; }
@media (max-width: 640px) { .hide-mobile { display: none; } }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }

/* ---------- Tooltip-ish note ---------- */
.note {
  background: var(--mint); border: 1px solid var(--mint-deep);
  border-radius: var(--radius-md); padding: 12px 14px;
  font-size: 0.9rem; color: var(--ink);
}
.note.warn  { background: var(--warn); border-color: var(--warn-border); }
.note.danger { background: var(--danger); border-color: #e89a9a; }
.note.lav   { background: var(--lavender); border-color: var(--lavender-deep); }

/* ---------- Toast (used by api.js showToast) ---------- */
.toast-region {
  position: fixed; top: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200; pointer-events: none;
}

/* ---------- Modal helpers (theme-aware) ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--surface-overlay);
  display: grid; place-items: center; z-index: 300; padding: 20px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px; max-width: 560px; width: 100%;
  box-shadow: var(--shadow-modal);
  color: var(--ink);
}
.modal-card h2 { margin-top: 0; }

/* ---------- Error message tone (helper for inline styles) ---------- */
.error-msg { color: var(--err-ink); font-size: .9rem; margin-top: .5rem; }

/* ---------- Inputs / selects used in admin filters + profile modal ---------- */
.input-narrow {
  padding: .5rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

/* ---------- KPI (metrics page) ---------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem;
  box-shadow: var(--shadow-kpi);
}

/* ---------- Admin logs hover row tint (theme-aware) ---------- */
.log-row-hover:hover { background: var(--hover-row-bg); }
