﻿/* ============================================
   IC3 Spark Level 1 — Theme Redesign
   Matching _ic3_themes design: light sky blue bg,
   white sidebar, playful rounded cards, Inter font
   ============================================ */

/* --- CSS Variables --- */
:root {
  --primary: #0EA5E9;
  --primary-dark: #0284C7;
  --primary-light: #E0F2FE;
  --purple: #9333EA;
  --purple-light: rgba(147, 51, 234, 0.1);
  --green: #22C55E;
  --green-dark: #16A34A;
  --green-light: #DCFCE7;
  --yellow: #FACC15;
  --yellow-dark: #EAB308;
  --yellow-light: #FEF9C3;
  --orange: #F97316;
  --red: #EF4444;
  --red-light: #FEE2E2;
  --lime: #84CC16;
  --lime-dark: #65A30D;
  --bg: #E0F2FE;
  --bg-history: #F0F9FF;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --card-bg: #ffffff;
  --border: #F1F5F9;
  --border-medium: #E2E8F0;
  --slate-50: #F8FAFC;
  --sidebar-width: 288px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- App Layout (sidebar + main) --- */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* --- Sidebar (White, Clean) --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--card-bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  padding: 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 40px;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
}

.sidebar-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

/* Sidebar Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--slate-50);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary);
  color: white;
}

.nav-link.active svg {
  stroke: white;
}

.nav-link svg {
  flex-shrink: 0;
  stroke: var(--text-secondary);
}

.nav-link:hover svg {
  stroke: var(--text);
}

/* Sidebar Module List */
.sidebar-modules {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.sidebar-modules-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.module-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.module-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.module-item:hover {
  background: var(--slate-50);
}

.module-item.active {
  background: var(--primary-light);
}

.module-item.active .module-item-title span:last-child {
  color: var(--primary);
}

.module-item-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.module-item:hover .module-item-title span:last-child {
  color: var(--primary);
}

.module-item-icon {
  font-size: 1.15rem;
}

.module-item-info {
  display: none;
}

.module-item-actions {
  display: none;
}

.module-item-loading {
  padding: 16px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.875rem;
}

/* Hidden sidebar buttons in new design */
.btn-review, .btn-exam-mini {
  display: none;
}

/* --- Main Content Area --- */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  min-height: 100vh;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* --- Exam Top Bar (Purple, shown during exam) --- */
.exam-top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: var(--purple);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  color: white;
  z-index: 200;
}

.exam-top-bar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exam-top-bar-icon {
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--purple);
  font-weight: 800;
  font-size: 0.7rem;
}

.exam-top-bar-text {
  font-size: 1.25rem;
  font-weight: 700;
}

.exam-top-bar-right {
  display: flex;
  align-items: center;
  gap: 32px;
}

.exam-top-bar-nav {
  display: flex;
  gap: 24px;
}

.exam-top-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
  padding-bottom: 4px;
}

.exam-top-link:hover {
  color: rgba(255,255,255,0.9);
}

.exam-top-link-active {
  color: white;
  border-bottom: 2px solid white;
}

/* Timer Display */
.timer-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.05rem;
}

.timer-display.warning {
  background: var(--red);
  animation: pulse 1s infinite;
}

.timer-icon {
  font-size: 1.1rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}


/* --- Welcome Message --- */
.welcome-message {
  text-align: center;
  margin-top: 12vh;
  color: var(--text-secondary);
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.welcome-message h1 {
  font-size: 1.8rem;
  color: var(--text);
  margin-bottom: 8px;
  font-weight: 700;
}

.welcome-message p {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.welcome-sub {
  color: var(--text-muted);
  font-size: 0.95rem !important;
}

/* --- Section Headers --- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

/* --- Dashboard Cards --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.dashboard-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.dashboard-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.card-icon-area {
  width: 64px;
  height: 64px;
  background: var(--slate-50);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.card-icon {
  font-size: 2rem;
}

.card-info {
  flex: 1;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}

.card-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* --- Progress Bar (Theme style) --- */
.progress-bar-container {
  width: 100%;
  height: 12px;
  background: var(--border);
  border-radius: 999px;
  overflow: visible;
  position: relative;
  margin-bottom: 32px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0EA5E9, #38BDF8);
  transition: width 0.5s ease;
  position: relative;
}

.progress-text {
  display: none;
}

/* --- Card Action Buttons --- */
.card-actions {
  display: flex;
  gap: 12px;
}

.btn-card {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 16px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-card:hover {
  opacity: 0.9;
}

.btn-card-review {
  background: var(--lime);
  color: white;
}

.btn-card-review:hover {
  background: var(--lime-dark);
}

.btn-card-exam {
  background: var(--yellow);
  color: white;
}

.btn-card-exam:hover {
  background: var(--yellow-dark);
}

/* --- Buttons (Pill / Rounded) --- */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-secondary);
  border: none;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: var(--slate-50);
}

.btn-success {
  background: var(--green);
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-success:hover {
  background: var(--green-dark);
}

.btn-submit {
  background: var(--green);
  color: white;
  border: none;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  width: auto;
  margin: 24px auto 0;
  display: block;
  transition: all 0.2s;
  box-shadow: var(--shadow-lg);
}

.btn-submit:hover {
  background: var(--green-dark);
  transform: scale(1.02);
}

.btn-submit:active {
  transform: scale(0.98);
}

.btn-next {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-next:hover {
  background: var(--primary-dark);
}

/* --- Quiz / Question Blocks --- */
.quiz-container {
  background: var(--card-bg);
  max-width: 900px;
  margin: 0 auto;
  padding: 40px;
  border-radius: 40px;
  box-shadow: var(--shadow);
  border: 4px solid var(--purple-light);
}

.module-title {
  color: var(--text);
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 20px;
  font-size: 1.3rem;
  font-weight: 700;
}

.question-block {
  margin-bottom: 24px;
  padding: 20px;
  background: var(--slate-50);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.question-text {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 16px;
  line-height: 1.6;
  color: var(--text);
}


/* --- Options (radio, checkbox) — Large card style --- */
.options-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: white;
  border-radius: 24px;
  cursor: pointer;
  border: 4px solid var(--border);
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
  line-height: 1.4;
  color: var(--text);
}

.option-label:hover {
  border-color: var(--border-medium);
  background: var(--slate-50);
}

.option-label input[type="radio"],
.option-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* Correct / Incorrect feedback on options */
.option-label.correct {
  background-color: var(--green-light) !important;
  border-color: var(--green) !important;
  font-weight: 700;
}

.option-label.incorrect {
  background-color: var(--red-light) !important;
  border-color: var(--red) !important;
}

/* --- Question Feedback --- */
.question-feedback {
  margin-top: 12px;
  padding: 14px 20px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 0.95rem;
}

.feedback-correct {
  background: var(--green-light);
  color: var(--green);
  border: 2px solid var(--green);
}

.feedback-incorrect {
  background: var(--red-light);
  color: var(--red);
  border: 2px solid var(--red);
}

/* --- Explanation Box --- */
.explanation-box {
  margin-top: 16px;
  padding: 16px 20px;
  background: var(--yellow-light);
  border: 2px solid var(--yellow);
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #92400e;
}

/* --- Drag & Drop --- */
.drag-drop-wrapper {
  padding: 4px 0;
}

.drag-instruction {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: 500;
}

.drag-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drag-item {
  padding: 16px 20px;
  background: white;
  border: 3px dashed var(--border-medium);
  border-radius: 16px;
  cursor: grab;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  user-select: none;
}

.drag-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.15);
}

.drag-item.dragging {
  opacity: 0.5;
  border-color: var(--primary);
  background: var(--primary-light);
}

.drag-item:active {
  cursor: grabbing;
}

.drag-fallback-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.drag-fallback-label {
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 80px;
}

.drag-fallback-select {
  flex: 1;
  padding: 10px 14px;
  border: 3px solid var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
  background: white;
  font-family: inherit;
}

/* --- Question Navigator (Exam Mode) — Round circles --- */
.question-navigator {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
  padding: 0;
  background: transparent;
  border: none;
}

.qnav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-medium);
  border-radius: 50%;
  background: white;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  position: relative;
}

.qnav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.qnav-btn.current {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

.qnav-btn.answered {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.qnav-btn.flagged {
  background: var(--yellow);
  border-color: var(--yellow);
  color: white;
}

.qnav-btn.flagged::after {
  content: '🚩';
  font-size: 0.5rem;
  position: absolute;
  top: -6px;
  right: -6px;
}

.qnav-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 100%;
}

.qnav-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qnav-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid;
}

/* --- Exam Header --- */
.exam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.exam-info {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.btn-flag {
  background: rgba(250, 204, 21, 0.1);
  color: var(--yellow-dark);
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s;
}

.btn-flag:hover {
  background: rgba(250, 204, 21, 0.2);
}

.btn-flag.flagged {
  background: var(--yellow);
  color: white;
  box-shadow: var(--shadow-lg);
}

/* --- Result Card --- */
.result-card {
  margin-top: 24px;
  padding: 32px;
  border-radius: 24px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.result-card.passed {
  background: var(--green-light);
  border: 3px solid var(--green);
  color: #166534;
}

.result-card.failed {
  background: var(--red-light);
  border: 3px solid var(--red);
  color: #991b1b;
}

.result-card .result-score {
  font-size: 3rem;
  font-weight: 800;
  margin: 8px 0;
}

.result-card .result-status {
  font-size: 1.4rem;
  margin-bottom: 12px;
}

.result-card .result-details {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-align: left;
  margin-top: 16px;
}

.result-card.correct {
  background-color: var(--green-light);
  border: 3px solid var(--green);
  color: #166534;
}

.result-card.incorrect {
  background-color: var(--red-light);
  border: 3px solid var(--red);
  color: #991b1b;
}

/* --- History View --- */
.history-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px;
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.history-item:hover {
  transform: scale(1.02);
  border-color: rgba(14, 165, 233, 0.2);
}

.history-icon-area {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  flex-shrink: 0;
}

.history-icon-area.passed {
  background: var(--green-light);
}

.history-icon-area.failed {
  background: var(--yellow-light);
}

.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.history-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

.history-item-title {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.history-item-score {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.history-item-status {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
}

.history-item-status.passed {
  background: var(--green);
  color: white;
}

.history-item-status.failed {
  background: var(--orange);
  color: white;
}

/* --- Chart Container --- */
.chart-container {
  background: var(--card-bg);
  border-radius: 32px;
  padding: 40px;
  box-shadow: var(--shadow);
  margin-bottom: 48px;
  position: relative;
  overflow: hidden;
}

.chart-container h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

.chart-container canvas {
  width: 100% !important;
  max-height: 300px;
}

/* --- Domain Score Bars --- */
.domain-scores {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
  text-align: left;
  background: var(--card-bg);
  padding: 24px;
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.domain-scores h3 {
  font-weight: 700;
}

.domain-score-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.domain-score-label {
  min-width: 160px;
  font-size: 0.875rem;
  font-weight: 600;
}

.domain-score-bar {
  flex: 1;
  height: 12px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.domain-score-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

.domain-score-fill.hardware { background: linear-gradient(90deg, #0EA5E9, #38BDF8); }
.domain-score-fill.software { background: linear-gradient(90deg, #9333EA, #A855F7); }
.domain-score-fill.networking { background: linear-gradient(90deg, #22C55E, #4ADE80); }

.domain-score-value {
  min-width: 60px;
  font-size: 0.875rem;
  font-weight: 700;
  text-align: right;
}

/* --- Review Summary --- */
.review-summary {
  background: var(--card-bg);
  border-radius: 32px;
  padding: 40px;
  box-shadow: var(--shadow);
  text-align: center;
}

.review-summary h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  color: var(--text);
  font-weight: 700;
}

.review-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-bottom: 24px;
}

.review-stat {
  text-align: center;
}

.review-stat-number {
  font-size: 2.5rem;
  font-weight: 800;
}

.review-stat-number.correct-num {
  color: var(--green);
}

.review-stat-number.incorrect-num {
  color: var(--red);
}

.review-stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.review-wrong-list {
  text-align: left;
  margin-top: 24px;
}

.review-wrong-list h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--red);
  font-weight: 700;
}

.review-wrong-item {
  padding: 12px 16px;
  background: var(--red-light);
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 1.05rem;
  margin-bottom: 16px;
}

/* --- Loading Spinner --- */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Exam Mode Layout (no sidebar) --- */
body.exam-mode .sidebar {
  display: none !important;
}

body.exam-mode .exam-top-bar {
  display: flex !important;
}

body.exam-mode .main-content {
  padding-top: 112px;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1280px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
    padding: 20px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .history-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 200px;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    padding: 12px 16px;
    gap: 16px;
    overflow-x: auto;
  }

  .sidebar-logo {
    margin-bottom: 0;
  }

  .sidebar-nav {
    flex-direction: row;
    gap: 4px;
  }

  .sidebar-modules {
    display: none;
  }

  .main-content {
    padding: 16px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .quiz-container {
    padding: 20px;
    border-radius: 24px;
  }

  .question-block {
    padding: 16px;
  }

  .option-label {
    padding: 14px 16px;
    border-radius: 16px;
    border-width: 3px;
  }

  .review-stats {
    gap: 24px;
  }

  .exam-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .question-navigator {
    gap: 6px;
  }

  .qnav-btn {
    width: 34px;
    height: 34px;
    font-size: 0.75rem;
  }

  .domain-score-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .domain-score-label {
    min-width: auto;
  }

  .domain-score-bar {
    width: 100%;
  }

  .chart-container {
    padding: 20px;
    border-radius: 24px;
  }

  body.exam-mode .main-content {
    padding-top: 96px;
  }

  .exam-top-bar {
    height: 64px;
    padding: 0 16px;
  }

  .exam-top-bar-nav {
    display: none;
  }
}

/* Ensure minimum font sizes */
@media screen {
  .question-text {
    font-size: max(1rem, 16px);
  }

  .option-label {
    font-size: max(0.875rem, 14px);
  }

  .drag-item {
    font-size: max(0.875rem, 14px);
  }

  .drag-fallback-select {
    font-size: max(0.875rem, 14px);
  }
}

/* --- Top Nav (legacy compat, hidden in new design) --- */
.top-nav {
  display: none;
}

.nav-links {
  list-style: none;
}

/* Sidebar header (legacy compat) */
.sidebar-header {
  display: none;
}

/* ============================================
   Student Name Dialog — Modal nhập tên
   ============================================ */

.sn-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.sn-modal {
  background: var(--card-bg);
  border-radius: 32px;
  padding: 48px 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: snSlideIn 0.3s ease;
}

@keyframes snSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sn-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.sn-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.sn-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.sn-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sn-input {
  width: 100%;
  padding: 14px 18px;
  border: 3px solid var(--border-medium);
  border-radius: 16px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.sn-input:focus {
  border-color: var(--primary);
}

.sn-input-error {
  border-color: var(--red) !important;
}

.sn-error {
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
}

.sn-confirm-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.2s;
}

.sn-confirm-btn:hover {
  background: var(--primary-dark);
}

/* Student name display on sidebar */
.student-name-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--primary-light);
  border-radius: 12px;
  margin-bottom: 16px;
}

.student-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.student-name-row:hover {
  opacity: 0.8;
}

.student-name-display:hover {
  background: #bae6fd;
}

.student-name-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.student-name-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.student-name-edit {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.student-logout-btn {
  width: 100%;
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.student-logout-btn:hover {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red);
}

/* ============================================
   Admin Panel — Bảng quản trị
   ============================================ */

.admin-pin-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.admin-pin-card {
  background: var(--card-bg);
  border-radius: 32px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.admin-pin-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.admin-pin-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.admin-pin-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.admin-pin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--card-bg);
  padding: 4px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.admin-tab {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.admin-tab:hover {
  background: var(--slate-50);
}

.admin-tab.active {
  background: var(--primary);
  color: white;
}

/* Admin Toolbar */
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.admin-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.admin-btn-danger {
  padding: 8px 16px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.2s;
}

.admin-btn-danger:hover {
  opacity: 0.9;
}

/* Admin Table */
.admin-table-wrapper {
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table thead {
  background: var(--slate-50);
}

.admin-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table td {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  color: var(--text);
}

.admin-table tbody tr:hover {
  background: var(--slate-50);
}

.admin-student-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.admin-student-link:hover {
  text-decoration: underline;
}

.admin-btn-delete {
  padding: 6px 12px;
  background: var(--red-light);
  color: var(--red);
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-btn-delete:hover {
  background: var(--red);
  color: white;
}

/* Admin Badge */
.admin-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-pass {
  background: var(--green-light);
  color: var(--green-dark);
}

.badge-fail {
  background: var(--red-light);
  color: var(--red);
}

/* Admin Detail Section */
.admin-detail-section {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.admin-detail-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* Admin Progress Item */
.admin-progress-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.admin-progress-item:last-child {
  border-bottom: none;
}

.admin-progress-label {
  font-weight: 600;
  color: var(--text);
  min-width: 120px;
}

.admin-progress-value {
  font-weight: 700;
  color: var(--primary);
}

.admin-progress-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Admin Settings */
.admin-settings-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
  max-width: 480px;
}

.admin-settings-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.admin-pin-change-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-pin-msg {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
}

.admin-pin-msg.error {
  background: var(--red-light);
  color: var(--red);
}

.admin-pin-msg.success {
  background: var(--green-light);
  color: var(--green-dark);
}

/* Responsive admin */
@media (max-width: 768px) {
  .admin-table-wrapper {
    overflow-x: auto;
  }

  .admin-toolbar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .admin-progress-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .admin-progress-date {
    margin-left: 0;
  }
}
