/* ============================================
   EduNaija — main.css
   Global reset, variables, typography, utilities
   ============================================ */

/* ── FONT IMPORTS ── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; outline: none; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── DESIGN TOKENS — DARK MODE (default) ── */
:root {
  /* Backgrounds */
  --bg:              #0d0d0d;
  --bg2:             #161616;
  --bg3:             #1f1f1f;
  --bg4:             #252525;
  --bg-hover:        #2a2a2a;

  /* Borders */
  --border:          #2a2a2a;
  --border-focus:    #f0a500;

  /* Brand */
  --gold:            #f0a500;
  --gold-dim:        #c48200;
  --gold-soft:       #f5c842;
  --gold-glow:       rgba(240, 165, 0, 0.12);
  --gold-glow-lg:    rgba(240, 165, 0, 0.20);

  /* Text */
  --text:            #f0f0f0;
  --text-sub:        #aaaaaa;
  --text-muted:      #666666;
  --text-inverse:    #0d0d0d;

  /* Status */
  --danger:          #e05c5c;
  --danger-soft:     rgba(224, 92, 92, 0.12);
  --success:         #4caf7d;
  --success-soft:    rgba(76, 175, 125, 0.12);
  --warning:         #f0a500;
  --info:            #4a9eff;

  /* Typography */
  --font-head:       'Playfair Display', Georgia, serif;
  --font-body:       'DM Sans', system-ui, sans-serif;
  --font-mono:       'JetBrains Mono', 'Fira Code', monospace;

  /* Font sizes */
  --text-xs:         11px;
  --text-sm:         13px;
  --text-base:       15px;
  --text-md:         17px;
  --text-lg:         20px;
  --text-xl:         24px;
  --text-2xl:        32px;
  --text-3xl:        48px;

  /* Spacing */
  --space-1:         4px;
  --space-2:         8px;
  --space-3:         12px;
  --space-4:         16px;
  --space-5:         20px;
  --space-6:         24px;
  --space-8:         32px;
  --space-10:        40px;
  --space-12:        48px;

  /* Layout */
  --sidebar-w:       280px;
  --nav-h:           58px;
  --input-bar-h:     80px;
  --max-msg-w:       720px;
  --radius-sm:       6px;
  --radius-md:       12px;
  --radius-lg:       18px;
  --radius-xl:       24px;
  --radius-full:     9999px;

  /* Shadows */
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.6);
  --shadow-gold:     0 0 20px rgba(240,165,0,0.2);

  /* Transitions */
  --ease:            cubic-bezier(0.4, 0, 0.2, 1);
  --transition:      0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── LIGHT MODE OVERRIDES ── */
[data-theme="light"] {
  --bg:              #ffffff;
  --bg2:             #f5f5f5;
  --bg3:             #eeeeee;
  --bg4:             #e8e8e8;
  --bg-hover:        #e0e0e0;
  --border:          #dddddd;
  --border-focus:    #c48200;
  --gold:            #c48200;
  --gold-dim:        #a06a00;
  --gold-soft:       #d4960a;
  --gold-glow:       rgba(196, 130, 0, 0.10);
  --gold-glow-lg:    rgba(196, 130, 0, 0.18);
  --text:            #111111;
  --text-sub:        #555555;
  --text-muted:      #999999;
  --text-inverse:    #ffffff;
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.1);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.16);
}

/* ── SYSTEM MODE ── */
@media (prefers-color-scheme: light) {
  [data-theme="system"] {
    --bg:              #ffffff;
    --bg2:             #f5f5f5;
    --bg3:             #eeeeee;
    --bg4:             #e8e8e8;
    --bg-hover:        #e0e0e0;
    --border:          #dddddd;
    --border-focus:    #c48200;
    --gold:            #c48200;
    --gold-dim:        #a06a00;
    --gold-soft:       #d4960a;
    --gold-glow:       rgba(196, 130, 0, 0.10);
    --gold-glow-lg:    rgba(196, 130, 0, 0.18);
    --text:            #111111;
    --text-sub:        #555555;
    --text-muted:      #999999;
    --text-inverse:    #ffffff;
    --shadow-sm:       0 1px 3px rgba(0,0,0,0.1);
    --shadow-md:       0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg:       0 8px 32px rgba(0,0,0,0.16);
  }
}

/* ── TYPOGRAPHY ── */
h1, h2, h3, h4 {
  font-family: var(--font-head);
  line-height: 1.2;
  color: var(--text);
}

.font-body { font-family: var(--font-body); }
.font-mono { font-family: var(--font-mono); }

.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-md    { font-size: var(--text-md); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }

.text-muted { color: var(--text-muted); }
.text-sub   { color: var(--text-sub); }
.text-gold  { color: var(--gold); }
.text-danger{ color: var(--danger); }

.fw-300 { font-weight: 300; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ── LAYOUT UTILITIES ── */
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.h-full { height: 100%; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--gold);
  color: var(--text-inverse);
}
.btn-primary:hover { background: var(--gold-soft); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--gold-dim); color: var(--gold); }

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover { border-color: var(--danger); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-sm { padding: 7px 14px; font-size: var(--text-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--text-base); }
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ── FORM INPUTS ── */
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-base);
  transition: var(--transition);
}
.input:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 3px var(--gold-glow); }
.input::placeholder { color: var(--text-muted); }

/* ── BADGE ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.badge-gold {
  background: var(--gold-glow);
  color: var(--gold);
  border: 1px solid var(--gold-dim);
}
.badge-green {
  background: var(--success-soft);
  color: var(--success);
}
.badge-red {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ── DIVIDER ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-4) 0;
}

/* ── PAGES ── */
.page {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.page.active { display: flex; }

/* ── OVERLAY ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}
.overlay.show {
  opacity: 1;
  pointer-events: all;
}

/* ── TOAST ── */
#toasts {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s var(--ease) both, toastOut 0.3s var(--ease) 2.7s both;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

/* ── MODAL ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: var(--space-6);
  animation: slideUp 0.3s var(--ease) both;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.modal-title {
  font-family: var(--font-head);
  font-size: var(--text-lg);
  color: var(--text);
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg3);
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg4); color: var(--text); }

/* ── FORMULA ── */
.formula {
  font-family: var(--font-mono);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  color: var(--gold-soft);
}

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.95); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ── LOADING SPINNER ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── RESPONSIVE ── */
@media (min-width: 768px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius-xl); }
}
