/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --primary: #3B1F8C;
  --primary-dark: #2A1566;
  --primary-light: #EDE9FF;
  --accent: #C4872A;
  --accent-light: #FEF3DC;
  --success: #2D7A4F;
  --success-light: #D1FAE5;
  --warning: #B45309;
  --warning-light: #FEF3C7;
  --danger: #9B2020;
  --danger-light: #FEE2E2;
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --border: #E8E5F0;
  --border-subtle: #F0EEF8;
  --text: #1A1625;
  --text-subtle: #6B6585;
  --text-light: #A09BBB;
  --sidebar-bg: #1A0F3C;
  --sidebar-text: #C4BAE8;
  --sidebar-active: rgba(255,255,255,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(59,31,140,.08), 0 1px 2px rgba(59,31,140,.04);
  --shadow: 0 4px 12px rgba(59,31,140,.1), 0 2px 4px rgba(59,31,140,.06);
  --shadow-md: 0 8px 24px rgba(59,31,140,.12), 0 4px 8px rgba(59,31,140,.06);
  --shadow-lg: 0 20px 40px rgba(59,31,140,.15);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  min-height: 100vh; font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
h1,h2,h3 { font-family: Georgia, 'Palatino Linotype', serif; letter-spacing: -.02em; }

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

.sidebar {
  width: 250px; background: var(--sidebar-bg);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(196,135,42,.08) 0%, transparent 40%);
}
.sidebar-brand {
  padding: 24px 20px 20px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .brand-title {
  font-family: Georgia, serif; font-size: .95rem; font-weight: 700;
  color: #fff; line-height: 1.3;
}
.sidebar-brand .brand-subtitle {
  font-size: .72rem; color: var(--sidebar-text); margin-top: 2px; opacity: .7;
}
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; color: var(--sidebar-text); font-size: .875rem;
  transition: all .2s; border-radius: var(--radius-sm); margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--sidebar-active); color: #fff; }
.sidebar-nav a.active {
  background: linear-gradient(135deg, rgba(196,135,42,.3), rgba(196,135,42,.15));
  color: #F5DFA0; border: 1px solid rgba(196,135,42,.3);
}
.sidebar-nav .nav-icon { font-size: 1rem; width: 18px; text-align: center; opacity: .9; }
.sidebar-section-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.25); padding: 16px 12px 6px;
}
.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-footer .username {
  color: #fff; font-weight: 600; font-size: .875rem; margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
  border-radius: var(--radius-sm); padding: 4px 6px; margin-left: -6px;
  transition: background .15s;
}
.sidebar-footer .username:hover { background: rgba(255,255,255,.1); }
.sidebar-footer .user-provider {
  font-size: .7rem; color: var(--sidebar-text); opacity: .7;
  background: rgba(255,255,255,.08); padding: 1px 8px; border-radius: 20px;
}
.logout-btn {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  color: var(--sidebar-text); padding: 6px 14px; border-radius: 6px; font-size: .8rem;
  width: 100%; transition: all .2s; text-align: center;
}
.logout-btn:hover { background: rgba(255,255,255,.14); color: #fff; }

.main-content { flex: 1; padding: 36px 40px; overflow-x: hidden; min-width: 0; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1A0F3C 0%, #3B1F8C 50%, #6B3AAF 100%);
  position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; inset: 0; opacity: .04;
  background-image: repeating-linear-gradient(45deg, #fff 0, #fff 1px, transparent 0, transparent 50%);
  background-size: 20px 20px;
}
.login-card {
  background: rgba(255,255,255,.98); backdrop-filter: blur(20px);
  border-radius: 20px; padding: 48px 44px; width: 100%;
  max-width: 420px; box-shadow: var(--shadow-lg); position: relative;
  border: 1px solid rgba(255,255,255,.5);
}
/* ── Login tabs ──────────────────────────────────────────────────────────── */
.login-tabs {
  display: flex; gap: 4px;
  background: var(--bg-muted); border-radius: var(--radius-sm); padding: 4px;
  margin-bottom: 24px;
}
.login-tab {
  flex: 1; padding: 8px 12px; border: none; border-radius: 6px;
  background: none; font-size: .875rem; font-weight: 600; cursor: pointer;
  color: var(--text-subtle); transition: all .2s;
}
.login-tab.active {
  background: #fff; color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon {
  font-size: 2.5rem; display: block; margin-bottom: 12px;
}
.login-logo h1 {
  font-size: 1.4rem; color: var(--primary); line-height: 1.2; font-weight: 700;
}
.login-logo p { color: var(--text-subtle); font-size: .85rem; margin-top: 4px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: .8rem; font-weight: 700; color: var(--text);
  margin-bottom: 6px; letter-spacing: .03em; text-transform: uppercase;
}
.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .9rem; transition: all .2s;
  background: var(--bg); color: var(--text);
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,31,140,.12); background: var(--surface);
}
.form-hint { font-size: .78rem; color: var(--text-subtle); margin-top: 4px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 20px; border-radius: var(--radius-sm); font-size: .875rem;
  font-weight: 600; border: none; transition: all .2s; white-space: nowrap;
  letter-spacing: .01em;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #5B33B8);
  color: #fff; box-shadow: 0 4px 12px rgba(59,31,140,.35);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px); box-shadow: 0 6px 16px rgba(59,31,140,.4);
}
.btn-accent {
  background: linear-gradient(135deg, var(--accent), #D4972E);
  color: #fff; box-shadow: 0 4px 12px rgba(196,135,42,.3);
}
.btn-accent:hover:not(:disabled) { transform: translateY(-1px); }
.btn-success {
  background: linear-gradient(135deg, var(--success), #37966E);
  color: #fff; box-shadow: 0 4px 8px rgba(45,122,79,.25);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #7F1A1A; }
.btn-ghost {
  background: transparent; color: var(--text-subtle);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--border-subtle); color: var(--text); border-color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: .78rem; border-radius: 6px; }
.btn-lg { padding: 13px 32px; font-size: 1rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; border-radius: 7px; }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 1.8rem; font-weight: 700; color: var(--text); }
.page-header p { color: var(--text-subtle); margin-top: 4px; font-size: .9rem; }
.page-header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}

/* ── Hero banner ─────────────────────────────────────────────────────────── */
.hero-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #5B33B8 60%, #7C4FCC 100%);
  border-radius: var(--radius); padding: 32px 36px; margin-bottom: 28px;
  color: #fff; display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.hero-banner::before {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.06); pointer-events: none;
}
.hero-banner::after {
  content: ''; position: absolute; right: 60px; bottom: -40px;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,.04); pointer-events: none;
}
.hero-banner h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.hero-banner p { opacity: .8; font-size: .875rem; }
.hero-banner .hero-icon { font-size: 3rem; opacity: .8; position: relative; z-index: 1; }

/* ── Stats grid ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); font-family: Georgia, serif; }
.stat-card .stat-label { font-size: .75rem; color: var(--text-subtle); margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }
.stat-card.stat-validated .stat-value { color: var(--success); }
.stat-card.stat-accent .stat-value { color: var(--accent); }
.stat-card.stat-danger .stat-value { color: var(--danger); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.card-body { padding: 24px; }
.card-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: .95rem; display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
}

/* ── Quiz list ───────────────────────────────────────────────────────────── */
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.quiz-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1.5px solid var(--border); box-shadow: var(--shadow-sm);
  transition: all .25s; overflow: hidden; display: flex; flex-direction: column;
}
.quiz-card:hover {
  box-shadow: var(--shadow-md); border-color: rgba(59,31,140,.3);
  transform: translateY(-2px);
}
.quiz-card-accent { height: 4px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.quiz-card-body { padding: 20px; flex: 1; }
.quiz-card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; color: var(--text); font-family: Georgia, serif; }
.quiz-card-desc { font-size: .83rem; color: var(--text-subtle); margin-bottom: 14px; min-height: 20px; line-height: 1.5; }
.quiz-card-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.quiz-card-count { font-size: .78rem; color: var(--text-light); }
.quiz-card-footer {
  padding: 12px 20px; border-top: 1px solid var(--border-subtle);
  background: var(--bg); display: flex; gap: 8px; align-items: center;
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700;
  letter-spacing: .03em; text-transform: uppercase;
}
.badge-not-started { background: var(--bg); color: var(--text-subtle); border: 1px solid var(--border); }
.badge-in-progress { background: var(--warning-light); color: var(--warning); border: 1px solid #FDE68A; }
.badge-validated { background: var(--success-light); color: var(--success); border: 1px solid #A7F3D0; }
.badge-primary { background: var(--primary-light); color: var(--primary); border: 1px solid #C4B5FD; }
.badge-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #FECACA; }
.badge-accent { background: var(--accent-light); color: var(--accent); border: 1px solid #FDE68A; }

/* ── Library filter pills ─────────────────────────────────────────────── */
.filter-pill {
  display: inline-flex; align-items: center;
  padding: 3px 12px; border-radius: 20px; font-size: .78rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-subtle);
  transition: background .15s, color .15s, border-color .15s;
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Toolbar control + reset button ─────────────────────────────────────── */
.ctrl-wrap { display: flex; align-items: center; gap: 4px; }
.ctrl-reset {
  background: none; border: none; cursor: pointer; padding: 3px 6px;
  border-radius: var(--radius-sm); font-size: .72rem; line-height: 1;
  color: var(--text-subtle); transition: color .15s, background .15s;
}
.ctrl-reset:hover { color: var(--danger); background: var(--danger-light); }

/* ── Admin table selected row ───────────────────────────────────────────── */
tr.row-selected td { background: var(--primary-light); }
tr.row-selected:hover td { background: #E4DCFF; }

/* ── Fullscreen quiz ─────────────────────────────────────────────────────── */
body.quiz-is-fullscreen .sidebar { display: none !important; }

body.quiz-is-fullscreen .main-content {
  padding: 40px !important;
  background: #2a2250;
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

body.quiz-is-fullscreen .quiz-container {
  max-width: 660px;
  width: 100%;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: #f5f3ff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  margin: 0;
  display: flex;
  flex-direction: column;
}

/* Illustration en haut du carré */
.quiz-cover-panel { display: none; }
body.quiz-is-fullscreen .quiz-cover-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a0f3c;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  flex-shrink: 0;
}
body.quiz-is-fullscreen .quiz-cover-panel img {
  max-height: 180px;
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  object-fit: contain;
}

/* Zone questions */
.quiz-main { flex: 1; }
body.quiz-is-fullscreen .quiz-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

/* ── Score display ───────────────────────────────────────────────────────── */
.score-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 20px; padding: 2px 10px; font-size: .8rem; font-weight: 700;
}

/* ── History ─────────────────────────────────────────────────────────────── */
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 6px; font-size: .82rem;
  background: var(--bg); margin-bottom: 4px; color: var(--text-subtle);
  border: 1px solid var(--border-subtle);
}

/* ── Quiz taking ─────────────────────────────────────────────────────────── */
.quiz-container { max-width: 720px; margin: 0 auto; }
.quiz-header { margin-bottom: 24px; }
.quiz-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 10px; font-family: Georgia, serif; }
.quiz-progress-bar { height: 6px; background: var(--border); border-radius: 3px; margin-bottom: 8px; overflow: hidden; }
.quiz-progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .4s ease;
}
.quiz-progress-text { font-size: .78rem; color: var(--text-subtle); }

.question-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1.5px solid var(--border); box-shadow: var(--shadow-md); padding: 32px;
}
.question-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.question-category {
  font-size: .75rem; font-weight: 700; color: var(--primary);
  background: var(--primary-light); padding: 4px 12px; border-radius: 20px;
  letter-spacing: .03em; text-transform: uppercase;
}
.question-type-hint { font-size: .75rem; color: var(--text-subtle); font-style: italic; }
.question-text { font-size: 1.15rem; font-weight: 600; line-height: 1.6; margin-bottom: 24px; color: var(--text); font-family: Georgia, serif; }

/* Timer */
.timer-bar { height: 6px; background: var(--border); border-radius: 3px; margin-bottom: 6px; overflow: hidden; }
.timer-fill {
  height: 100%; border-radius: 3px; transition: width 1s linear, background-color .5s;
  background: linear-gradient(90deg, var(--success), #68D391);
}
.timer-fill.warning { background: linear-gradient(90deg, var(--warning), #FBBF24); }
.timer-fill.danger { background: linear-gradient(90deg, var(--danger), #F87171); }
.timer-text { font-size: .78rem; color: var(--text-subtle); text-align: right; margin-bottom: 20px; }

/* Choices */
.choices-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.choice-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .18s; background: var(--surface);
}
.choice-item:hover { border-color: var(--primary); background: var(--primary-light); }
.choice-item.selected {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,31,140,.1);
}
.choice-item input[type="radio"], .choice-item input[type="checkbox"] {
  accent-color: var(--primary); width: 18px; height: 18px; flex-shrink: 0;
}
.choice-text { font-size: .95rem; line-height: 1.4; }
.quiz-actions { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

/* ── Results ─────────────────────────────────────────────────────────────── */
.results-container { max-width: 620px; margin: 0 auto; }
.results-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #5B33B8 100%);
  border-radius: var(--radius); padding: 40px; text-align: center; margin-bottom: 24px;
  color: #fff; box-shadow: var(--shadow-md);
}
.results-hero.perfect {
  background: linear-gradient(135deg, var(--success) 0%, #10B981 100%);
}
.results-score { font-size: 4rem; font-weight: 700; font-family: Georgia, serif; line-height: 1; }
.results-score-label { font-size: .875rem; opacity: .8; margin-top: 4px; }
.results-title { font-size: 1.5rem; font-weight: 700; margin-top: 16px; }
.results-subtitle { opacity: .8; margin-top: 6px; font-size: .875rem; }

.category-scores { margin-bottom: 24px; }
.category-score-item { margin-bottom: 16px; }
.category-score-header { display: flex; justify-content: space-between; font-size: .875rem; margin-bottom: 6px; }
.category-score-name { font-weight: 700; }
.category-score-pct { color: var(--text-subtle); }
.category-score-bar { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.category-score-fill { height: 100%; border-radius: 5px; transition: width .8s cubic-bezier(.4,0,.2,1); }

/* ── Profile ─────────────────────────────────────────────────────────────── */
.profile-header {
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--primary) 100%);
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 24px;
  color: #fff; display: flex; align-items: center; gap: 20px;
  box-shadow: var(--shadow-md);
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.15); display: flex; align-items: center;
  justify-content: center; font-size: 1.8rem; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.3);
}
.profile-info h2 { font-size: 1.4rem; font-weight: 700; }
.profile-info .profile-role {
  font-size: .78rem; background: rgba(255,255,255,.15);
  padding: 2px 10px; border-radius: 20px; display: inline-block; margin-top: 4px;
}
.profile-info .profile-provider { font-size: .75rem; opacity: .7; margin-top: 4px; }

.radar-section { margin-bottom: 24px; }
.radar-label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); margin-bottom: 12px; }

/* ── Admin ───────────────────────────────────────────────────────────────── */
.admin-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.admin-tab {
  padding: 10px 20px; font-size: .875rem; font-weight: 600;
  color: var(--text-subtle); background: none; border: none;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  cursor: pointer; transition: all .18s; white-space: nowrap;
}
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-tab:hover { color: var(--text); }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  text-align: left; padding: 10px 16px; border-bottom: 2px solid var(--border);
  font-weight: 700; color: var(--text-subtle); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .07em; white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--bg); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,22,37,.55);
  backdrop-filter: blur(4px); display: flex; align-items: center;
  justify-content: center; z-index: 1000; padding: 20px; animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 16px; width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-sm { max-width: 440px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 860px; }
.modal-header {
  padding: 22px 28px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; font-family: Georgia, serif; }
.modal-close {
  background: var(--bg); border: 1px solid var(--border); font-size: 1rem;
  color: var(--text-subtle); line-height: 1; padding: 5px 9px; border-radius: 6px;
  transition: all .15s;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.modal-body { padding: 28px; }
.modal-footer {
  padding: 16px 28px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Question editor ─────────────────────────────────────────────────────── */
.question-editor { border: 1.5px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; transition: border-color .15s; }
.question-editor:hover { border-color: rgba(59,31,140,.25); }
.question-editor-header {
  padding: 12px 16px; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.question-editor-body { padding: 14px 16px; border-top: 1px solid var(--border-subtle); }
.choice-editor-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.choice-editor-row input[type="checkbox"] { accent-color: var(--success); width: 16px; height: 16px; flex-shrink: 0; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: .875rem;
  margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-light); color: var(--danger); border-color: #FECACA; }
.alert-success { background: var(--success-light); color: var(--success); border-color: #A7F3D0; }
.alert-info { background: var(--primary-light); color: var(--primary); border-color: #C4B5FD; }

/* ── Upload ──────────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 44px; text-align: center; cursor: pointer; transition: all .2s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-zone p { color: var(--text-subtle); font-size: .875rem; }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: .875rem; font-weight: 600; }
.toggle-hint { font-size: .75rem; color: var(--text-subtle); margin-top: 2px; }
.toggle-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 24px;
  cursor: pointer; transition: .25s;
}
.toggle-slider:before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: .25s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ── Log table ───────────────────────────────────────────────────────────── */
.log-filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-subtle); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }

/* ── Loading ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Progress bar generic ────────────────────────────────────────────────── */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .6s cubic-bezier(.4,0,.2,1); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-content { padding: 24px 20px; }
  .sidebar { width: 220px; }
}
@media (max-width: 680px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-nav { display: flex; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
  .sidebar-nav a { padding: 8px 12px; white-space: nowrap; }
  .sidebar-section-title { display: none; }
  .main-content { padding: 20px 16px; }
  .quiz-grid { grid-template-columns: 1fr; }
  .hero-banner { flex-direction: column; text-align: center; }
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-subtle); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.fw-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
