/* =========================================================
   BrightPath School — Design System
========================================================= */
:root {
  --primary: #4338ca;
  --primary-dark: #3730a3;
  --primary-light: #eef2ff;
  --accent: #0d9488;
  --accent-light: #ccfbf1;
  --gold: #d97706;
  --gold-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #16a34a;
  --success-light: #dcfce7;
  --ink: #1e1b2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f6f7fb;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 12px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.10);
  font-size: 15px;
}

/* Dark mode — toggled via a data-theme="dark" attribute on <html>, persisted in a cookie so it
   applies before first paint (no flash of light mode). Same variable names, different values,
   so every component below "just works" without extra dark-mode-specific rules. */
html[data-theme="dark"] {
  --primary: #818cf8;
  --primary-dark: #a5b4fc;
  --primary-light: #2a2a4a;
  --accent: #2dd4bf;
  --accent-light: #164e4a;
  --gold: #fbbf24;
  --gold-light: #4a3a12;
  --danger: #f87171;
  --danger-light: #4a1e1e;
  --success: #4ade80;
  --success-light: #1a3a26;
  --ink: #e8e8f0;
  --muted: #9ca3af;
  --border: #33334d;
  --bg: #14141f;
  --card: #1c1c2e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
}
html[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #14121f, #0d0b16); }
html[data-theme="dark"] .auth-wrap { background: radial-gradient(circle at top left, #4338ca 0%, #0d0b16 65%); }
html[data-theme="dark"] .landing-hero,
html[data-theme="dark"] .landing-nav { color: #e8e8f0; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1,h2,h3,h4 { margin: 0 0 .5em; line-height: 1.25; }
p { margin: 0 0 1em; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  background: linear-gradient(180deg, #241f3d, #1a1630);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  transition: transform .25s ease;
  z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1.4rem 1.2rem; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #f59e0b);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #241f3d; font-size: .9rem;
}
.brand-name { font-weight: 700; font-size: 1.02rem; letter-spacing: .2px; }
.sidebar-nav { flex: 1; padding: .5rem .7rem; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .68rem .8rem; margin-bottom: .15rem;
  border-radius: 10px; color: rgba(255,255,255,.72);
  font-size: .92rem; font-weight: 500; transition: all .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: var(--gold); color: #241f3d; font-weight: 700; }
.sidebar-nav .ic { font-size: 1rem; width: 1.1rem; text-align: center; }
.sidebar-footer { padding: 1rem 1.2rem; border-top: 1px solid rgba(255,255,255,.08); }
.logout-link { color: rgba(255,255,255,.65); font-size: .9rem; display: flex; gap: .5rem; align-items:center;}
.logout-link:hover { color: #fff; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 66px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem;
  position: sticky; top: 0; z-index: 30;
}
.menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; }
.page-title { font-size: 1.15rem; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 1.1rem; }
.notif-bell { position: relative; font-size: 1.2rem; cursor: pointer; }
.notif-badge {
  position: absolute; top: -6px; right: -8px; background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700; padding: 1px 5px; border-radius: 999px;
}
.user-chip { display: flex; align-items: center; gap: .55rem; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem;
}
.user-name { font-weight: 600; font-size: .88rem; }
.user-role-badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--accent);
  background: var(--accent-light); padding: 2px 7px; border-radius: 6px; letter-spacing: .3px;
}

.content { padding: 1.6rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.content-guest { min-height: 100vh; }

/* ---------- Alerts ---------- */
.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem; font-weight: 500; }
.alert-success { background: var(--success-light); color: #15803d; }
.alert-error { background: var(--danger-light); color: #b91c1c; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }
.alert-warning { background: var(--gold-light); color: #92400e; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-header h3 { margin: 0; font-size: 1rem; }

.stat-card { display: flex; flex-direction: column; gap: .3rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-card .stat-icon { font-size: 1.4rem; margin-bottom: .3rem; }
.stat-trend { font-size: .78rem; font-weight: 600; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .62rem 1.1rem; border-radius: 10px; border: none; font-weight: 600; font-size: .88rem;
  cursor: pointer; transition: all .15s; text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #b45309; }
.btn-outline { background: #fff; border: 1.5px solid var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .4rem .75rem; font-size: .78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.1rem; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: #374151; }
input, select, textarea {
  width: 100%; padding: .68rem .85rem; border: 1.5px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: .9rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.form-row { display: flex; gap: 1rem; }
.form-row > * { flex: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { text-align: left; padding: .75rem .9rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: .72rem; letter-spacing: .3px; background: #fafafc; }
tr:hover td { background: #fafafe; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-success { background: var(--success-light); color: #15803d; }
.badge-warning { background: var(--gold-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #b91c1c; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }
.badge-muted { background: #f1f2f6; color: var(--muted); }

/* ---------- Progress bars ---------- */
.progress-track { height: 9px; background: #eef0f5; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; }

/* ---------- Tutor / product cards ---------- */
.tutor-card { display: flex; flex-direction: column; gap: .7rem; }
.tutor-card-top { display: flex; gap: .9rem; align-items: center; }
.tutor-avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; flex-shrink: 0;
}
.tutor-name { font-weight: 700; font-size: .98rem; }
.tutor-meta { font-size: .78rem; color: var(--muted); }
.tutor-rating { color: var(--gold); font-weight: 700; font-size: .82rem; }
.tutor-subjects { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: var(--accent-light); color: #0f766e; font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.tutor-price { font-weight: 800; color: var(--primary); font-size: 1.05rem; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top left, #4338ca 0%, #1a1630 65%);
  padding: 2rem;
}
.auth-card {
  background: #fff; border-radius: 18px; padding: 2.4rem; width: 100%; max-width: 430px;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand-mark { margin: 0 auto 1rem; }
.auth-title { text-align: center; font-size: 1.3rem; font-weight: 800; margin-bottom: .2rem; }
.auth-sub { text-align: center; color: var(--muted); font-size: .87rem; margin-bottom: 1.6rem; }
.auth-switch { text-align: center; font-size: .85rem; margin-top: 1.2rem; color: var(--muted); }
.auth-switch a { color: var(--primary); font-weight: 700; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1.1rem; }
.role-pick label {
  border: 1.5px solid var(--border); border-radius: 10px; padding: .7rem; text-align: center;
  font-size: .82rem; cursor: pointer; font-weight: 600; color: var(--muted);
}
.role-pick input { display: none; }
.role-pick input:checked + span { color: var(--primary); }
.role-pick label:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ---------- Voice input mic button ---------- */
.mic-btn { font-size: 1rem; }
.mic-btn.mic-listening { animation: mic-pulse 1s infinite; }
@keyframes mic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ---------- Rich text editor ---------- */
.richtext-wrap { border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; }
.richtext-toolbar { display: flex; gap: 2px; padding: .4rem; background: #fafafc; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
html[data-theme="dark"] .richtext-toolbar { background: #16162a; }
.richtext-btn {
  background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: .3rem .6rem;
  font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink); min-width: 30px;
}
.richtext-btn:hover { background: var(--primary-light); border-color: var(--primary); }
html[data-theme="dark"] .richtext-btn { background: var(--card); }
.richtext-editable {
  min-height: 160px; padding: .8rem; font-size: .9rem; line-height: 1.6; outline: none; background: #fff; color: var(--ink);
}
html[data-theme="dark"] .richtext-editable { background: var(--card); }
.richtext-editable:focus { box-shadow: inset 0 0 0 2px var(--primary-light); }
.richtext-editable ul, .richtext-editable ol { padding-left: 1.4rem; margin: .4rem 0; }
.richtext-editable h4 { margin: .4rem 0; }
.richtext-editable a { color: var(--primary); }

/* ---------- Password show/hide toggle ---------- */
.password-field { position: relative; }
.password-field input { padding-right: 2.6rem; }
.password-toggle {
  position: absolute; top: 50%; right: .7rem; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: .3rem; line-height: 1;
  color: var(--muted); font-size: 1.05rem; display: flex; align-items: center;
}
.password-toggle:hover { color: var(--ink); }
.password-toggle svg { width: 20px; height: 20px; }

/* ---------- Landing page ---------- */
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 1.3rem 5%; }
.landing-nav .brand-name { color: #fff; font-size: 1.1rem; }
.landing-hero { color: #fff; text-align: center; padding: 4rem 5% 6rem; max-width: 780px; margin: 0 auto; }
.landing-hero h1 { font-size: 2.6rem; font-weight: 800; margin-bottom: .8rem; }
.landing-hero p { font-size: 1.05rem; color: rgba(255,255,255,.82); margin-bottom: 2rem; }
.hero-actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.features-strip { background: #fff; padding: 4rem 5%; }
.features-strip .grid { max-width: 1100px; margin: 0 auto; }
.feature-item { text-align: left; }
.feature-item .stat-icon { font-size: 1.8rem; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .stat-icon { font-size: 2.4rem; display: block; margin-bottom: .6rem; }
.locked-overlay {
  position: relative; padding: 1.5rem; text-align: center; background: var(--gold-light);
  border-radius: var(--radius); border: 1.5px dashed var(--gold);
}

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
}
