/* ═══════════════════════════════════════════════════════════════
   EduVerse — Advanced Components
   Lesson viewer, Quiz, Activities, Dashboard widgets, AI Tutor
   ═══════════════════════════════════════════════════════════════ */

/* ━━━━━━━━━━━━━━━━ LESSON PAGE ━━━━━━━━━━━━━━━━ */
.lesson-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  max-width: var(--max-w);
  margin: 24px auto;
  padding: 0 20px;
}
@media (max-width: 1024px) {
  .lesson-shell { grid-template-columns: 1fr; }
  .lesson-sidebar { position: static !important; }
}

.lesson-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 20px);
  align-self: start;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.lesson-sidebar h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.sidebar-item {
  display: block;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-2);
  font-weight: 600;
  transition: all var(--t-fast);
  margin-bottom: 2px;
}
.sidebar-item:hover { background: var(--bg-sunken); color: var(--brand-600); }
.sidebar-item.active {
  background: var(--brand-100);
  color: var(--brand-700);
  border-right: 3px solid var(--brand-500);
}
[data-theme="dark"] .sidebar-item.active { background: rgba(168,85,247,0.15); }

.lesson-main {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 40px;
  min-height: 600px;
}
@media (max-width: 640px) { .lesson-main { padding: 24px; } }

.lesson-header {
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.lesson-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 12px;
}
.lesson-breadcrumb a { color: var(--text-3); }
.lesson-breadcrumb a:hover { color: var(--brand-600); }
.lesson-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.lesson-title-row h1 {
  font-size: clamp(24px, 3.5vw, 34px);
  line-height: 1.25;
}
.lesson-meta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Lesson actions bar */
.lesson-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ━━━━━━━━━━━━━━━━ QUIZ ━━━━━━━━━━━━━━━━ */
.quiz-shell {
  max-width: 820px;
  margin: 24px auto;
  padding: 0 20px;
}
.quiz-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 36px;
  box-shadow: var(--sh-md);
}
@media (max-width: 640px) { .quiz-card { padding: 22px; } }
.quiz-progress-bar {
  height: 6px;
  background: var(--bg-sunken);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: 24px;
}
.quiz-progress-bar > span {
  display: block;
  height: 100%;
  background: var(--g-aurora);
  transition: width 400ms var(--ease-out);
}
.quiz-q-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.quiz-q-count .count {
  font-weight: 800;
  color: var(--text-3);
  font-size: 14px;
}
.quiz-q-count .timer {
  font-weight: 800;
  font-family: var(--font-mono);
  background: var(--bg-sunken);
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: 13px;
}

.quiz-question {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 24px;
}

.quiz-options {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}
.quiz-option {
  width: 100%;
  padding: 18px 20px;
  border: 2px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: right;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  transition: all var(--t-base) var(--ease-out);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}
.quiz-option:hover:not(:disabled) {
  border-color: var(--brand-500);
  transform: translateX(-4px);
  box-shadow: var(--sh-sm);
}
.quiz-option .letter {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--bg-sunken);
  color: var(--text-3);
  font-weight: 900;
  display: grid; place-items: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: all var(--t-base);
}
.quiz-option:hover .letter { background: var(--brand-100); color: var(--brand-700); }
.quiz-option.selected { border-color: var(--brand-500); background: var(--brand-50); }
.quiz-option.selected .letter { background: var(--g-aurora); color: #fff; }
[data-theme="dark"] .quiz-option.selected { background: rgba(168,85,247,0.15); }
.quiz-option.correct { border-color: #10b981; background: #d1fae5; color: #065f46; }
.quiz-option.correct .letter { background: var(--g-success); color: #fff; }
[data-theme="dark"] .quiz-option.correct { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.quiz-option.wrong { border-color: #ef4444; background: #fee2e2; color: #991b1b; }
.quiz-option.wrong .letter { background: var(--g-danger); color: #fff; }
[data-theme="dark"] .quiz-option.wrong { background: rgba(239,68,68,0.18); color: #fca5a5; }
.quiz-option:disabled { cursor: default; }

/* Answer reveal (for short/long) */
.quiz-answer-reveal {
  background: var(--bg-sunken);
  border-right: 4px solid var(--brand-500);
  padding: 16px 20px;
  border-radius: var(--r-md);
  margin-bottom: 20px;
  animation: fadeUp 0.4s var(--ease-out);
}
.quiz-answer-reveal h5 {
  color: var(--brand-600);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Quiz result screen */
.result-screen { text-align: center; padding: 20px 0; }
.result-medal {
  width: 140px; height: 140px;
  display: grid; place-items: center;
  font-size: 80px;
  border-radius: 50%;
  margin: 0 auto 20px;
  background: var(--g-aurora);
  box-shadow: var(--sh-xl);
  animation: popIn 0.6s var(--ease-spring);
}
.result-score {
  font-size: 64px;
  font-weight: 900;
  background: var(--g-aurora);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
  margin: 10px 0;
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 28px 0;
}
.result-stat {
  background: var(--bg-sunken);
  padding: 16px 12px;
  border-radius: var(--r-md);
}
.result-stat .v { font-size: 24px; font-weight: 900; color: var(--brand-600); }
.result-stat .l { font-size: 12px; color: var(--text-3); font-weight: 700; }

/* ━━━━━━━━━━━━━━━━ ACTIVITIES ━━━━━━━━━━━━━━━━ */
.activity-shell {
  max-width: 860px;
  margin: 24px auto;
  padding: 0 20px;
}

/* Flashcards */
.flashcard-deck { position: relative; height: 320px; perspective: 1200px; margin: 32px 0; }
.flashcard {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  transition: transform 0.7s var(--ease-out);
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  border-radius: var(--r-xl);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
  box-shadow: var(--sh-lg);
  font-weight: 800;
}
.flashcard-front {
  background: var(--g-aurora);
  color: #fff;
  font-size: 32px;
}
.flashcard-back {
  background: var(--bg-elev);
  color: var(--text);
  font-size: 22px;
  border: 2px solid var(--border-strong);
  transform: rotateY(180deg);
}
.flashcard-face p { font-size: inherit; color: inherit; margin: 0; }

/* Matching */
.matching-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 24px 0;
}
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 700;
  transition: all var(--t-fast);
  text-align: right;
  font-size: 14.5px;
}
.match-item:hover { border-color: var(--brand-500); }
.match-item.selected { border-color: var(--brand-500); background: var(--brand-50); }
[data-theme="dark"] .match-item.selected { background: rgba(168,85,247,0.15); }
.match-item.matched {
  border-color: #10b981;
  background: #d1fae5;
  color: #065f46;
  cursor: default;
  opacity: 0.65;
}
[data-theme="dark"] .match-item.matched { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.match-item.wrong {
  animation: shake 0.4s;
  border-color: #ef4444;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Fill blank */
.fillblank-q {
  padding: 22px;
  background: var(--bg-sunken);
  border-radius: var(--r-md);
  margin-bottom: 14px;
  font-size: 17px;
  line-height: 1.9;
}
.fillblank-q input {
  display: inline-block;
  width: auto;
  min-width: 140px;
  padding: 4px 10px;
  margin: 0 6px;
  border: 2px solid var(--brand-500);
  background: var(--bg-elev);
  border-radius: 6px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-700);
  text-align: center;
}

/* ━━━━━━━━━━━━━━━━ DASHBOARD ━━━━━━━━━━━━━━━━ */
.dash-hero {
  background: var(--g-aurora);
  border-radius: var(--r-xl);
  padding: 36px;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 32px;
}
.dash-hero::before {
  content: '';
  position: absolute;
  top: -60px; left: -60px;
  width: 240px; height: 240px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}
.dash-hero::after {
  content: '';
  position: absolute;
  bottom: -80px; right: -80px;
  width: 320px; height: 320px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.dash-hero > * { position: relative; z-index: 1; }
.dash-hero h1 { color: #fff; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-base);
}
.kpi:hover { transform: translateY(-4px); box-shadow: var(--sh-md); }
.kpi .label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.kpi .value {
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}
.kpi .delta { font-size: 13px; color: #10b981; font-weight: 700; margin-top: 6px; }
.kpi .icon {
  position: absolute;
  top: 20px; left: 20px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: var(--r-sm);
  background: var(--brand-100);
  color: var(--brand-600);
}
[data-theme="dark"] .kpi .icon { background: rgba(168,85,247,0.15); }

/* Streak flame */
.streak-widget {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-radius: var(--r-lg);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--sh-md);
}
.streak-widget .flame {
  font-size: 32px;
  animation: flame 1.5s ease-in-out infinite;
}
@keyframes flame {
  0%,100% { transform: scale(1) rotate(-3deg); }
  50% { transform: scale(1.15) rotate(3deg); }
}

/* Achievements */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}
.achievement {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 12px;
  text-align: center;
  transition: all var(--t-base);
}
.achievement.locked { opacity: 0.4; filter: grayscale(1); }
.achievement:not(.locked):hover { transform: translateY(-4px); box-shadow: var(--sh-md); }
.achievement .emoji { font-size: 44px; line-height: 1; margin-bottom: 8px; }
.achievement .name { font-size: 13px; font-weight: 800; color: var(--text); }
.achievement .desc { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* Leaderboard */
.leaderboard {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 60px 1fr 100px 100px;
  align-items: center;
  padding: 14px 20px;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row:hover { background: var(--bg-sunken); }
.leaderboard-row .rank {
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  color: var(--text-3);
}
.leaderboard-row.top1 .rank::before { content: '🥇'; }
.leaderboard-row.top2 .rank::before { content: '🥈'; }
.leaderboard-row.top3 .rank::before { content: '🥉'; }
.leaderboard-row.top1 .rank, .leaderboard-row.top2 .rank, .leaderboard-row.top3 .rank {
  font-size: 26px;
}
.leaderboard-row.me { background: var(--brand-50); font-weight: 800; }
[data-theme="dark"] .leaderboard-row.me { background: rgba(168,85,247,0.1); }
.leaderboard-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--g-aurora);
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  margin-left: 10px;
}
.leaderboard-user { display: flex; align-items: center; }
.leaderboard-name { font-weight: 700; color: var(--text); }
.leaderboard-xp { text-align: center; font-weight: 900; color: var(--brand-600); }
.leaderboard-level { text-align: center; }
.level-pill {
  display: inline-block;
  padding: 3px 10px;
  background: var(--brand-100);
  color: var(--brand-700);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 800;
}
[data-theme="dark"] .level-pill { background: rgba(168,85,247,0.15); color: var(--brand-300); }

@media (max-width: 640px) {
  .leaderboard-row { grid-template-columns: 40px 1fr 80px; }
  .leaderboard-level { display: none; }
}

/* ━━━━━━━━━━━━━━━━ AI TUTOR ━━━━━━━━━━━━━━━━ */
#ai-fab {
  position: fixed;
  bottom: 22px;
  left: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 14px 18px;
  background: var(--g-aurora);
  color: #fff;
  border: 0;
  border-radius: var(--r-full);
  box-shadow: var(--sh-xl);
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  z-index: 999;
  transition: all var(--t-base) var(--ease-spring);
  animation: pulse-ring 2s infinite;
}
#ai-fab:hover { transform: translateY(-4px) scale(1.05); }
#ai-fab i { font-size: 18px; }
@media (max-width: 640px) {
  #ai-fab span { display: none; }
  #ai-fab { padding: 16px; width: 56px; height: 56px; justify-content: center; }
}

.ai-panel {
  position: fixed;
  bottom: 22px;
  left: 22px;
  width: min(420px, calc(100vw - 44px));
  height: min(600px, calc(100vh - 44px));
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  animation: popIn 0.3s var(--ease-spring);
}
.ai-panel.open { display: flex; }

.ai-header {
  padding: 16px 20px;
  background: var(--g-aurora);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-header h3 { color: #fff; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.ai-header .close {
  background: rgba(255,255,255,0.2);
  border: 0; color: #fff;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
}

.ai-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-msg {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 14.5px;
  line-height: 1.6;
  animation: fadeUp 0.3s var(--ease-out);
}
.ai-msg.user {
  background: var(--g-aurora);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.ai-msg.bot {
  background: var(--bg-sunken);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.ai-msg.bot.typing {
  display: flex; gap: 4px;
  padding: 14px 16px;
}
.ai-msg.bot.typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-500);
  animation: dot 1.4s infinite ease-in-out both;
}
.ai-msg.bot.typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-msg.bot.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot { 0%,80%,100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

.ai-quick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 16px 8px;
}
.ai-quick .chip {
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg-sunken);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  cursor: pointer;
}
.ai-quick .chip:hover { background: var(--brand-100); color: var(--brand-700); }

.ai-input-row {
  padding: 12px 16px 16px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.ai-input-row input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--r-md);
  font-family: inherit;
  color: var(--text);
}
.ai-input-row input:focus { outline: none; border-color: var(--brand-500); }
.ai-input-row button {
  width: 46px; height: 46px;
  border: 0;
  background: var(--g-aurora);
  color: #fff;
  border-radius: var(--r-md);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 16px;
}
.ai-input-row button:disabled { opacity: 0.6; cursor: not-allowed; }

/* ━━━━━━━━━━━━━━━━ LIBRARY / FILTERS ━━━━━━━━━━━━━━━━ */
.library-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  transition: all var(--t-fast);
  max-width: 380px;
  flex: 1;
}
.search-box:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 4px var(--ring); }
.search-box i { color: var(--text-3); }
.search-box input {
  flex: 1;
  height: 44px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
}
.search-box input:focus { outline: none; }

/* Subjects grid same as subject-card above */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

/* ━━━━━━━━━━━━━━━━ PRICING ━━━━━━━━━━━━━━━━ */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.pricing-card {
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px 28px;
  position: relative;
  transition: all var(--t-base);
}
.pricing-card:hover { transform: translateY(-6px); box-shadow: var(--sh-lg); }
.pricing-card.featured {
  border-color: transparent;
  background: var(--g-aurora);
  color: #fff;
  transform: scale(1.03);
}
.pricing-card.featured::before {
  content: 'الأكثر شيوعاً';
  position: absolute;
  top: -14px; right: 50%; transform: translateX(50%);
  background: var(--g-sunrise);
  color: #fff;
  padding: 6px 18px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 900;
}
.pricing-card.featured p, .pricing-card.featured li { color: rgba(255,255,255,0.92); }
.pricing-card h3 { font-size: 20px; margin-bottom: 8px; }
.pricing-card .price { margin: 20px 0; }
.pricing-card .price .amount { font-size: 50px; font-weight: 900; line-height: 1; }
.pricing-card .price .per { font-size: 14px; color: var(--text-3); }
.pricing-card.featured .price .per { color: rgba(255,255,255,0.85); }
.pricing-card ul { list-style: none; padding: 0; margin: 20px 0; }
.pricing-card li { padding: 8px 0; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.pricing-card li::before { content: '✓'; color: var(--brand-500); font-weight: 900; }
.pricing-card.featured li::before { color: #fff; }

/* ━━━━━━━━━━━━━━━━ AUTH PAGES ━━━━━━━━━━━━━━━━ */
.auth-shell {
  min-height: calc(100vh - var(--nav-h));
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 44px 36px;
  box-shadow: var(--sh-xl);
  max-width: 440px;
  width: 100%;
}
.auth-card h1 { font-size: 28px; margin-bottom: 8px; }
.auth-card .subtitle { color: var(--text-3); margin-bottom: 28px; }

/* ━━━━━━━━━━━━━━━━ ADMIN ━━━━━━━━━━━━━━━━ */
.admin-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  max-width: var(--max-w);
  margin: 24px auto;
  padding: 0 20px;
  min-height: calc(100vh - 180px);
}
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-sidebar {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: calc(var(--nav-h) + 20px);
}
.admin-sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 4px;
  transition: all var(--t-fast);
}
.admin-sidebar a:hover { background: var(--bg-sunken); color: var(--text); }
.admin-sidebar a.active {
  background: var(--g-aurora);
  color: #fff;
}
.admin-content {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
}

/* Table */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.admin-table th, .admin-table td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  background: var(--bg-sunken);
  font-weight: 800;
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-table tr:hover { background: var(--bg-sunken); }

/* ═══════════════════════════════════════════════════════════════
   EDUVERSE v3 — NEW COMPONENTS
   Legal pages · Contact · Pricing-contact · Activities-hub
   CMS editor · Admin additions · Theme picker
   ═══════════════════════════════════════════════════════════════ */

/* ━━━━━━━━━━ CMS PUBLIC PAGES (privacy/terms/contact) ━━━━━━━━━━ */
.cms-page { padding: 20px 0; }
.cms-hero { text-align:center; padding: 30px 20px 40px; }
.cms-hero-icon { font-size: 72px; margin-bottom: 14px; filter: drop-shadow(0 8px 20px rgba(168,85,247,0.25)); }
.cms-hero h1 { font-size: clamp(32px, 5vw, 48px); margin: 0 0 8px; line-height: 1.2; }
.cms-updated { color: var(--text-3); font-size: 14px; margin: 0; }
.cms-content-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px 32px;
  box-shadow: var(--sh-md);
}

/* Prose / Markdown rendering */
.prose { font-size: 16px; line-height: 1.85; color: var(--text-2); }
.prose h1 { font-size: 28px; font-weight: 900; margin: 32px 0 14px; color: var(--text); line-height: 1.3; }
.prose h2 { font-size: 24px; font-weight: 900; margin: 28px 0 12px; color: var(--text); line-height: 1.35;
  padding-bottom: 10px; border-bottom: 2px solid var(--border); }
.prose h3 { font-size: 19px; font-weight: 800; margin: 22px 0 10px; color: var(--text); }
.prose h4 { font-size: 17px; font-weight: 800; margin: 18px 0 8px; color: var(--text); }
.prose p { margin: 14px 0; }
.prose ul, .prose ol { padding-inline-start: 24px; margin: 14px 0; }
.prose li { margin: 6px 0; }
.prose strong { color: var(--text); font-weight: 800; }
.prose a { color: var(--brand-600); text-decoration: underline; text-underline-offset: 3px; font-weight: 700; }
.prose a:hover { color: var(--brand-700); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 30px 0; }
.prose code { background: var(--bg-sunken); padding: 2px 8px; border-radius: 6px; font-family: var(--font-mono); font-size: 0.9em; color: var(--brand-600); }
.prose blockquote {
  border-inline-start: 4px solid var(--brand-500);
  padding: 12px 20px;
  margin: 18px 0;
  background: var(--bg-sunken);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-2);
  font-style: italic;
}
.prose table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.prose th, .prose td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: start; }
.prose th { background: var(--bg-sunken); font-weight: 800; }

/* ━━━━━━━━━━ CONTACT PAGE ━━━━━━━━━━ */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 30px 0;
}
.contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-decoration: none;
  color: inherit;
  transition: transform var(--t-base) var(--ease-spring), box-shadow var(--t-base);
  box-shadow: var(--sh-sm);
}
.contact-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--sh-lg);
  border-color: var(--border-strong);
}
.contact-ico {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 22px;
  box-shadow: var(--sh-md);
}
.contact-body { flex: 1; min-width: 0; }
.contact-label { font-size: 13px; color: var(--text-3); font-weight: 700; margin-bottom: 4px; }
.contact-value { font-weight: 800; font-size: 17px; color: var(--text); word-break: break-word; }
.contact-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.grid-2-contact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 40px;
}
.grid-2-contact > div { min-width: 0; }
@media (max-width: 840px) { .grid-2-contact { grid-template-columns: 1fr; } }

.contact-form-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--sh-md);
}

/* ━━━━━━━━━━ PRICING — CONTACT-BASED ━━━━━━━━━━ */
.howit-banner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 10px;
  padding: 22px 20px;
  background: var(--g-mesh), var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin: 28px 0;
  flex-wrap: wrap;
}
.howit-step { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 220px; }
.howit-num {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--g-aurora); color: #fff;
  display: grid; place-items: center;
  font-weight: 900; font-size: 18px;
  box-shadow: var(--sh-md);
  flex-shrink: 0;
}
.howit-step strong { display: block; font-size: 15px; margin-bottom: 2px; }
.howit-step p { margin: 0; font-size: 13px; color: var(--text-3); }
.howit-arrow { color: var(--text-4); font-size: 14px; }
@media (max-width: 720px) { .howit-arrow { display: none; } }

.pricing-badge {
  position: absolute;
  top: 14px; inset-inline-end: 14px;
  background: var(--bg-sunken);
  color: var(--text-2);
  font-size: 11px; font-weight: 800;
  padding: 5px 10px;
  border-radius: var(--r-full);
}
.pricing-card { position: relative; }

.contact-callout {
  display: flex; align-items: center; gap: 20px;
  padding: 24px 28px;
  margin-top: 32px;
  background: var(--g-mesh), var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  flex-wrap: wrap;
}
.contact-callout-ico {
  font-size: 48px;
  width: 72px; height: 72px;
  border-radius: var(--r-md);
  background: var(--g-aurora);
  display: grid; place-items: center;
  box-shadow: var(--sh-md);
  flex-shrink: 0;
}
.contact-callout-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ━━━━━━━━━━ LOGIN — REQUEST ACCOUNT ━━━━━━━━━━ */
.request-account-card {
  background: var(--bg-sunken);
  border-radius: var(--r-md);
  padding: 18px 20px;
  margin: 20px 0;
}
.rac-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  font-size: 14px; font-weight: 600; color: var(--text-2);
}
.rac-step:not(:last-child) { border-bottom: 1px dashed var(--border); }
.rac-step span {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--g-aurora); color: #fff;
  display: grid; place-items: center;
  font-weight: 900; font-size: 13px;
  flex-shrink: 0;
}
.auth-contact-btns { display: flex; flex-direction: column; gap: 0; margin-top: 20px; }

/* ━━━━━━━━━━ ACTIVITIES HUB — REDESIGNED ━━━━━━━━━━ */
.activities-hub { padding-bottom: 80px; }

.act-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 30px 0 40px;
}
@media (max-width: 680px) { .act-stats-row { grid-template-columns: repeat(2, 1fr); } }

.act-stat-card {
  text-align: center;
  padding: 22px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: transform var(--t-base) var(--ease-spring);
}
.act-stat-card:hover { transform: translateY(-4px); box-shadow: var(--sh-md); }
.act-stat-num { font-size: 36px; font-weight: 900; line-height: 1; margin-bottom: 6px; }
.act-stat-label { font-size: 13px; color: var(--text-3); font-weight: 700; }

.acth-title {
  font-size: 22px; font-weight: 900;
  margin: 40px 0 16px;
  display: flex; align-items: center; gap: 10px;
}
.acth-title i { color: var(--brand-500); }

.act-types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 40px;
}
.act-type-card {
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 18px;
  text-align: center;
  transition: all var(--t-base) var(--ease-spring);
  cursor: default;
}
.act-type-card:hover {
  transform: translateY(-4px);
  border-color: var(--tc, var(--brand-500));
  box-shadow: 0 12px 30px color-mix(in srgb, var(--tc, var(--brand-500)) 25%, transparent);
}
.act-type-emoji {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  color: #fff; font-size: 22px; font-weight: 900;
  margin-bottom: 12px;
  box-shadow: var(--sh-md);
}
.act-type-name { font-weight: 900; font-size: 16px; margin-bottom: 4px; }
.act-type-desc { font-size: 13px; color: var(--text-3); min-height: 36px; }
.act-type-count {
  display: inline-block; margin-top: 10px;
  background: var(--bg-sunken);
  padding: 4px 12px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 800; color: var(--text-2);
}

.act-filters {
  position: sticky;
  top: calc(var(--nav-h) + 8px);
  z-index: 10;
  background: var(--surface-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 28px;
  box-shadow: var(--sh-sm);
}
.act-search { max-width: 100%; margin-bottom: 10px; }
.act-subj-chips {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.act-subj-chips .chip {
  display: inline-flex; align-items: center; gap: 6px;
}
.chip-count {
  background: var(--bg);
  color: var(--text-3);
  padding: 1px 8px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 800;
  margin-inline-start: 4px;
}
.chip.active .chip-count { background: rgba(255,255,255,0.25); color: #fff; }

.act-subject-group {
  margin-bottom: 32px;
}
.act-subject-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 10px;
}
.act-subj-left { display: flex; align-items: center; gap: 12px; }
.act-subj-emoji {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: 22px;
  box-shadow: var(--sh-sm);
}

.act-lessons-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.act-lesson-card {
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  padding: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: all var(--t-base) var(--ease-spring);
  min-height: 170px;
}
.act-lesson-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
  border-color: var(--border-strong);
}
.act-lesson-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.act-lesson-badge {
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 800;
  letter-spacing: 2px;
}
.act-lesson-count {
  font-size: 12px; font-weight: 800; color: var(--text-3);
  display: flex; align-items: center; gap: 4px;
}
.act-lesson-title {
  font-size: 15px; font-weight: 800;
  margin: 0 0 6px; line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.act-lesson-summary {
  font-size: 12.5px; color: var(--text-3);
  margin: 0 0 12px; line-height: 1.55;
  flex: 1;
}
.act-lesson-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: auto; padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
}

/* ━━━━━━━━━━ ADMIN ADDITIONS ━━━━━━━━━━ */
.side-badge {
  background: var(--accent-500); color: #fff;
  padding: 2px 8px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 900;
  margin-inline-start: auto;
  min-width: 22px; text-align: center;
}

/* CMS editor layout */
.cms-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  margin-top: 10px;
}
@media (max-width: 860px) { .cms-layout { grid-template-columns: 1fr; } }

.cms-list {
  display: flex; flex-direction: column; gap: 8px;
}
.cms-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-align: start;
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  color: inherit;
}
.cms-list-item:hover { border-color: var(--border-strong); background: var(--bg-sunken); }
.cms-list-item.active {
  border-color: var(--brand-500);
  background: var(--surface);
  box-shadow: var(--sh-sm);
}
.cms-list-title { font-weight: 800; margin-bottom: 2px; font-size: 14px; }
.cms-list-sub { font-size: 12px; }

.cms-editor { padding: 24px; }
.cms-editor-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 16px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 10px;
}
.cms-editor-head h3 { margin: 0; font-size: 18px; }

.cms-textarea {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  min-height: 380px;
  resize: vertical;
}

/* Messages list */
.msg-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin-bottom: 10px;
  transition: all var(--t-fast);
}
.msg-item.unread { border-inline-start: 4px solid var(--brand-500); background: var(--surface); }
.msg-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; }
.msg-from { font-size: 15px; }
.msg-body {
  margin-top: 10px; padding: 10px 14px;
  background: var(--bg-sunken); border-radius: var(--r-sm);
  font-size: 14px; line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}

/* ━━━━━━━━━━ THEME PICKER UPGRADES ━━━━━━━━━━ */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}
.theme-chip {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  color: inherit;
  text-align: start;
  overflow: hidden;
}
.theme-chip:hover {
  border-color: var(--brand-500);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}
.theme-chip.active {
  border-color: var(--brand-500);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--ring);
}
.theme-chip-swatch {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  box-shadow: var(--sh-sm);
  border: 1px solid rgba(0,0,0,0.08);
}
/* Per-theme swatch previews (live mini-gradient) */
.theme-chip-swatch[data-swatch="light"]    { background: linear-gradient(135deg,#a855f7,#ec4899,#06b6d4); }
.theme-chip-swatch[data-swatch="dark"]     { background: linear-gradient(135deg,#05050f,#1a1a40); }
.theme-chip-swatch[data-swatch="ocean"]    { background: linear-gradient(135deg,#0ea5e9,#14b8a6,#6366f1); }
.theme-chip-swatch[data-swatch="sunset"]   { background: linear-gradient(135deg,#f97316,#ef4444,#fbbf24); }
.theme-chip-swatch[data-swatch="forest"]   { background: linear-gradient(135deg,#16a34a,#84cc16,#0891b2); }
.theme-chip-swatch[data-swatch="galaxy"]   { background: linear-gradient(135deg,#6366f1,#a855f7,#ec4899); }
.theme-chip-swatch[data-swatch="rose"]     { background: linear-gradient(135deg,#f43f5e,#ec4899,#a855f7); }
.theme-chip-swatch[data-swatch="midnight"] { background: linear-gradient(135deg,#8b5cf6,#3b82f6,#06b6d4); }
.theme-chip-swatch[data-swatch="candy"]    { background: linear-gradient(135deg,#f472b6,#fbbf24,#34d399); }
.theme-chip-swatch[data-swatch="nordic"]   { background: linear-gradient(135deg,#64748b,#38bdf8,#7dd3fc); }
.theme-chip-swatch[data-swatch="gold"]     { background: linear-gradient(135deg,#d4a017,#f59e0b,#b91c1c); }
.theme-chip-swatch[data-swatch="mono"]     { background: linear-gradient(135deg,#030712,#374151,#9ca3af); }
.theme-chip-swatch[data-swatch="mint"]     { background: linear-gradient(135deg,#14b8a6,#22c55e,#06b6d4); }
.theme-chip-swatch[data-swatch="cyber"]    { background: linear-gradient(135deg,#a855f7,#00d4ff,#22ff88); }
.theme-chip-swatch[data-swatch="coffee"]   { background: linear-gradient(135deg,#8b5e3c,#d97706,#a16207); }
.theme-chip-swatch[data-swatch="emerald"]  { background: linear-gradient(135deg,#059669,#10b981,#fbbf24); }
.theme-chip-swatch[data-swatch="lavender"] { background: linear-gradient(135deg,#a78bfa,#c4b5fd,#e0e7ff); }
.theme-chip-swatch[data-swatch="oman"]     { background: linear-gradient(135deg,#c8102e,#d4a017,#009739); }
.theme-chip-swatch[data-swatch="aurora"]   { background: linear-gradient(135deg,#10b981,#22d3ee,#8b5cf6); }

.theme-chip-body { flex: 1; min-width: 0; }
.theme-chip-emoji { font-size: 14px; margin-inline-end: 4px; }
.theme-chip-name { font-size: 13px; font-weight: 700; }
.theme-chip-check {
  position: absolute; top: 6px; inset-inline-end: 6px;
  color: var(--brand-500); font-size: 14px;
}

/* Tiny utility */
.justify-between { justify-content: space-between; }
