/* ==========================================================================
   Base: design tokens, reset, shared components (used by dashboard + admin)
   ========================================================================== */

:root {
  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  /* dark (default) */
  --bg: #07070d;
  --bg-2: #0e0d1a;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .075);
  --surface-solid: #12111f;
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #eeedff;
  --text-2: #c3c2dd;
  --muted: #8988a6;
  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --accent-ink: #ffffff;
  --green: #2ee59d;
  --amber: #ffb020;
  --pink: #ff5c8a;
  --danger: #ff5470;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, .7);
  --glow: 0 0 0 1px rgba(124, 92, 255, .35), 0 10px 40px -10px rgba(124, 92, 255, .55);
  --aurora-1: #6d4bff;
  --aurora-2: #00b7ff;
  --aurora-3: #ff3d8b;
  --aurora-opacity: .5;
  --grid-line: rgba(255, 255, 255, .035);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f2fb;
    --bg-2: #e9e7f7;
    --surface: rgba(255, 255, 255, .72);
    --surface-2: rgba(255, 255, 255, .95);
    --surface-solid: #ffffff;
    --border: rgba(30, 24, 80, .09);
    --border-strong: rgba(30, 24, 80, .18);
    --text: #15132b;
    --text-2: #3a3858;
    --muted: #6d6b8a;
    --accent: #6a46ff;
    --accent-2: #0096d6;
    --shadow: 0 20px 50px -24px rgba(40, 30, 110, .35);
    --glow: 0 0 0 1px rgba(106, 70, 255, .3), 0 10px 30px -12px rgba(106, 70, 255, .45);
    --aurora-opacity: .28;
    --grid-line: rgba(30, 24, 80, .045);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3f2fb;
  --bg-2: #e9e7f7;
  --surface: rgba(255, 255, 255, .72);
  --surface-2: rgba(255, 255, 255, .95);
  --surface-solid: #ffffff;
  --border: rgba(30, 24, 80, .09);
  --border-strong: rgba(30, 24, 80, .18);
  --text: #15132b;
  --text-2: #3a3858;
  --muted: #6d6b8a;
  --accent: #6a46ff;
  --accent-2: #0096d6;
  --shadow: 0 20px 50px -24px rgba(40, 30, 110, .35);
  --glow: 0 0 0 1px rgba(106, 70, 255, .3), 0 10px 30px -12px rgba(106, 70, 255, .45);
  --aurora-opacity: .28;
  --grid-line: rgba(30, 24, 80, .045);
  color-scheme: light;
}

/* ---- reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.02em; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- background ----------------------------------------------------------- */
.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; opacity: var(--aurora-opacity); }
.aurora span {
  position: absolute; border-radius: 50%; filter: blur(90px);
  width: 46vmax; height: 46vmax; animation: drift 26s var(--ease) infinite alternate;
}
.aurora span:nth-child(1) { background: var(--aurora-1); top: -18vmax; left: -10vmax; }
.aurora span:nth-child(2) { background: var(--aurora-2); bottom: -22vmax; right: -12vmax; animation-delay: -8s; }
.aurora span:nth-child(3) { background: var(--aurora-3); top: 30%; left: 45%; width: 28vmax; height: 28vmax; opacity: .55; animation-delay: -16s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vmax, 4vmax) scale(1.12); }
  100% { transform: translate(-4vmax, 7vmax) scale(.95); }
}
.grid-overlay {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 75%);
}

/* ---- cards ---------------------------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head h2 svg, .card-head h3 svg { color: var(--accent-2); font-size: 18px; }

/* ---- buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s;
}
.btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { font-size: 17px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-2)));
  border-color: transparent; color: var(--accent-ink); box-shadow: var(--glow);
}
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-size: 18px; color: var(--text-2);
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }

/* ---- chips ---------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 500; color: var(--text-2);
  white-space: nowrap;
}
.chip svg { font-size: 14px; }
.chip-c { /* course-tinted chip, set --c inline */
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent);
  border-color: color-mix(in srgb, var(--c, var(--accent)) 40%, transparent);
  color: color-mix(in srgb, var(--c, var(--accent)) 70%, var(--text));
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; box-shadow: 0 0 10px var(--c, var(--accent)); }

/* ---- forms ---------------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.field small { color: var(--muted); font-size: 12px; }
.input, .field input:not([type="checkbox"]):not([type="color"]), .field select, .field textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.field select option { background: var(--surface-solid); color: var(--text); }

.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 17px; }
.search .input { padding-left: 38px; min-width: 240px; }

/* ---- modal ---------------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 4, 15, .6); backdrop-filter: blur(6px); animation: fade .2s; }
.modal-card {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 26px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); animation: pop .28s var(--ease);
}
.modal-close { position: absolute; top: 14px; right: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ---- toast ---------------------------------------------------------------- */
.toasts { position: fixed; z-index: 200; bottom: 20px; right: 20px; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; min-width: 240px; max-width: 380px;
  background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: pop .25s var(--ease);
  font-size: 14px;
}
.toast.ok { border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.toast.err { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.toast svg { font-size: 18px; }
.toast.ok svg { color: var(--green); }
.toast.err svg { color: var(--danger); }

/* ---- loading -------------------------------------------------------------- */
.loading { display: flex; gap: 8px; justify-content: center; padding: 80px 0; }
.loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: bounce 1s infinite ease-in-out; }
.loading span:nth-child(2) { animation-delay: .15s; background: var(--accent-2); }
.loading span:nth-child(3) { animation-delay: .3s; background: var(--pink); }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.empty {
  display: grid; place-items: center; gap: 10px; text-align: center; padding: 36px 16px; color: var(--muted);
}
.empty svg { font-size: 34px; color: var(--accent); opacity: .7; }
.empty b { color: var(--text); font-family: var(--font-display); font-size: 17px; }

.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .8s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
