/* ========== CSS Reset & Variables ========== */
:root {
  --primary: #4F46E5;
  --primary-light: #818CF8;
  --primary-dark: #3730A3;
  --primary-bg: #EEF2FF;
  --success: #059669;
  --success-bg: #ECFDF5;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);
  --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  min-height: 100vh;
}

/* ========== Utility ========== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.page { display: none; animation: fadeIn 0.4s ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-100px) rotate(720deg); opacity: 0; }
}

/* ========== Header ========== */
.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 24px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.app-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
  animation: none;
  pointer-events: none;
}

.app-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  position: relative;
  z-index: 1;
}

.app-header p {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 6px;
  position: relative;
  z-index: 1;
}

/* ========== Cards ========== */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 20px;
  transition: var(--transition);
  border: 1px solid var(--gray-100);
}

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

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title .icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.form-select, .form-input, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--gray-800);
  background: white;
  transition: var(--transition);
  outline: none;
  font-family: inherit;
}

.form-select:focus, .form-input:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: white;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.btn-success:hover {
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.45);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  color: white;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}

.btn-danger:hover {
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.45);
  transform: translateY(-2px);
}

.btn-outline {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
}

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

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
  border-radius: var(--radius-xs);
}

.btn-block {
  width: 100%;
}

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

/* ========== Landing Page ========== */
.landing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 30px;
}

.landing-card {
  background: white;
  border-radius: var(--radius);
  padding: 40px 28px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
}

.landing-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary-light);
}

.landing-card .landing-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  display: block;
}

.landing-card h3 {
  font-size: 1.25rem;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.landing-card p {
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* ========== Quiz Interface ========== */
.quiz-header {
  position: sticky;
  top: 0;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.quiz-timer {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quiz-progress {
  flex: 1;
  margin: 0 20px;
}

.quiz-progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.quiz-progress-text {
  font-size: 0.8rem;
  color: var(--gray-500);
  text-align: center;
  margin-top: 4px;
}

.quiz-layout {
  display: flex;
  gap: 20px;
  padding: 20px 20px 0;
  max-width: 1200px;
  margin: 0 auto;
}

.quiz-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 160px);
}

.quiz-body {
  flex: 1;
  padding-bottom: 20px;
}

.question-card {
  display: none;
  animation: scaleIn 0.3s ease;
}

.question-card.active {
  display: block;
}

.question-number {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.question-stem {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.7;
  margin-bottom: 20px;
}

.question-stem img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  box-shadow: var(--shadow-sm);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  background: white;
}

.option-item:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
  transform: translateX(4px);
}

.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.option-label {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-600);
  flex-shrink: 0;
  transition: var(--transition);
}

.option-item.selected .option-label {
  background: var(--primary);
  color: white;
}

.option-text {
  flex: 1;
  padding-top: 5px;
  font-size: 1rem;
  color: var(--gray-800);
  line-height: 1.5;
}

.option-image {
  max-width: 100%;
  border-radius: var(--radius-xs);
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
}

/* ========== Quiz Footer ========== */
.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-top: auto;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.quiz-nav-btn {
  padding: 10px 20px;
  border-radius: var(--radius-xs);
  border: 2px solid var(--gray-200);
  background: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.quiz-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== Quiz Sidebar ========== */
.quiz-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 80px;
  align-self: flex-start;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.quiz-sidebar-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-100);
}

@media (max-width: 900px) {
  .quiz-layout {
    flex-direction: column;
    padding-bottom: 100px;
  }

  .quiz-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    order: -1;
  }
}

/* ========== Question Map (导航) ========== */
.question-map {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.question-map-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid var(--gray-200);
  background: white;
  color: var(--gray-500);
}

.question-map-dot.answered {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
}

.question-map-dot.current {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: scale(1.1);
}

/* ========== Result Page ========== */
.result-hero {
  text-align: center;
  padding: 40px 20px;
  animation: slideUp 0.5s ease;
}

.result-score {
  font-size: 5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.result-score-label {
  font-size: 1rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin: 30px 0;
}

.result-stat {
  text-align: center;
  padding: 20px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

.result-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}

.result-stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ========== Rankings ========== */
.rank-table {
  width: 100%;
  border-collapse: collapse;
}

.rank-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--gray-50);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
}

.rank-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.95rem;
}

.rank-table tr:hover td {
  background: var(--gray-50);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
}

.rank-1 { background: #FEF3C7; color: #92400E; }
.rank-2 { background: #F3F4F6; color: #4B5563; }
.rank-3 { background: #FDE8D8; color: #9A3412; }
.rank-other { background: var(--gray-100); color: var(--gray-600); }

.rank-pager {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pager-btn {
  padding: 6px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--gray-700);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.pager-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pager-info {
  font-size: 0.85rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.score-bar {
  display: inline-block;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  min-width: 20px;
  transition: width 1s ease;
}

/* ========== Tab Switcher ========== */
.tab-bar {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.tab-item {
  flex: 1;
  padding: 10px 16px;
  text-align: center;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--gray-500);
  border: none;
  background: none;
  font-family: inherit;
}

.tab-item.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ========== Teacher Dashboard ========== */
.teacher-layout {
  display: flex;
  min-height: 100vh;
}

.teacher-sidebar {
  width: 240px;
  background: var(--gray-900);
  color: white;
  padding: 24px 16px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
}

.teacher-sidebar .logo {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 12px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  color: var(--gray-400);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.sidebar-link.active {
  background: rgba(79, 70, 229, 0.3);
  color: white;
}

.teacher-main {
  flex: 1;
  margin-left: 240px;
  padding: 28px 32px;
}

.teacher-page {
  display: none;
  animation: fadeIn 0.3s ease;
}

.teacher-page.active {
  display: block;
}

/* ========== Question Edit Form ========== */
.option-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-100);
}

.option-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-top: 6px;
}

.option-marker-a { background: #DBEAFE; color: #1E40AF; }
.option-marker-b { background: #FCE7F3; color: #9D174D; }
.option-marker-c { background: #FEF3C7; color: #92400E; }
.option-marker-d { background: #D1FAE5; color: #065F46; }

.option-content {
  flex: 1;
}

.option-content input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-xs);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
  font-family: inherit;
}

.option-content input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.option-image-upload {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.option-image-upload img {
  max-height: 60px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--gray-200);
}

.correct-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--gray-500);
}

.correct-toggle input[type="radio"] {
  accent-color: var(--success);
  width: 18px;
  height: 18px;
}

.correct-toggle.is-correct {
  color: var(--success);
  font-weight: 600;
}

/* ========== Question List ========== */
.question-list-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: white;
  transition: var(--transition);
}

.question-list-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--gray-300);
}

.question-list-num {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.question-list-body {
  flex: 1;
  min-width: 0;
}

.question-list-stem {
  font-size: 0.95rem;
  color: var(--gray-800);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.question-list-answer {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
  margin-top: 6px;
}

.question-list-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ========== Stats Cards ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 20px;
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--gray-900);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ========== Modal ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  animation: scaleIn 0.3s ease;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  color: white;
  font-weight: 500;
  font-size: 0.9rem;
  animation: slideInRight 0.3s ease;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--primary); }

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

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

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ========== Confirm Dialog ========== */
.confirm-dialog {
  text-align: center;
}

.confirm-dialog .confirm-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.confirm-dialog h3 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.confirm-dialog p {
  color: var(--gray-500);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .landing-grid {
    grid-template-columns: 1fr;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }

  .teacher-sidebar {
    display: none;
  }

  .teacher-main {
    margin-left: 0;
  }

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

  .quiz-header {
    padding: 10px 14px;
  }

  .quiz-timer {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 20px;
  }

  .app-header h1 {
    font-size: 1.4rem;
  }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ========== File Upload ========== */
.file-upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--gray-50);
}

.file-upload-area:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.file-upload-area input[type="file"] {
  display: none;
}

.file-upload-area .upload-hint {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.file-upload-area .upload-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

/* ========== Import Area ========== */
.import-area textarea {
  width: 100%;
  min-height: 200px;
  padding: 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: var(--transition);
}

.import-area textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.import-hint {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 8px;
  line-height: 1.5;
}

/* ========== Loading ========== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  flex-direction: column;
  gap: 16px;
  color: var(--gray-400);
}

/* ========== Highlight Row ========== */
.highlight-row td {
  background: var(--primary-bg) !important;
  font-weight: 600;
}

/* ========== Wrong Answers Page ========== */
.wrong-answer-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  animation: slideUp 0.4s ease;
}

.wrong-answer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}

.wrong-answer-num {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 4px 12px;
  border-radius: 20px;
}

.wrong-answer-correct {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--success);
  background: var(--success-bg);
  padding: 4px 12px;
  border-radius: 20px;
}

.wrong-answer-stem {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.7;
  margin-bottom: 18px;
}

.wrong-answer-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wrong-option-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  background: white;
  position: relative;
}

.wrong-option-correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.wrong-option-selected {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.wrong-option-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.wrong-option-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

.correct-badge {
  background: var(--success);
  color: white;
}

.wrong-badge {
  background: var(--danger);
  color: white;
}

/* ========== Image preview in quiz ========== */
.quiz-image-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
}

.quiz-image-preview:hover {
  transform: scale(1.02);
}

/* Image lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
}
