/* ============================================
   QuizB — Custom CSS (Tailwind Supplement)
   ============================================ */

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 9999px; }
.dark ::-webkit-scrollbar-thumb { background: #374151; }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.25rem;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 0.625rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99,102,241,0.45);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  padding: 0.5rem 1.25rem;
  background: transparent;
  color: #6366f1;
  font-weight: 600; font-size: 0.875rem;
  border-radius: 0.625rem;
  border: 1.5px solid #6366f1;
  cursor: pointer; transition: all 0.2s ease; text-decoration: none;
}
.btn-secondary:hover { background: #eff0ff; }
.dark .btn-secondary { color: #818cf8; border-color: #818cf8; }
.dark .btn-secondary:hover { background: #1e1b4b; }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  padding: 0.5rem 1.25rem;
  background: #ef4444; color: white;
  font-weight: 600; font-size: 0.875rem; border-radius: 0.625rem;
  border: none; cursor: pointer; transition: all 0.2s;
}
.btn-danger:hover { background: #dc2626; }

/* ---- Cards ---- */
.card {
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: 0 8px 30px rgba(0,0,0,0.1); }
.dark .card { background: #111827; border-color: #1f2937; }

.card-hover:hover { transform: translateY(-2px); }

/* ---- Form Inputs ---- */
.form-input {
  display: block; width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem; font-family: inherit;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 0.5rem;
  color: #111827;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); background: #fff; }
.dark .form-input { background: #1f2937; border-color: #374151; color: #f9fafb; }
.dark .form-input:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129,140,248,0.15); background: #111827; }

.form-label {
  display: block; font-size: 0.875rem; font-weight: 500;
  color: #374151; margin-bottom: 0.375rem;
}
.dark .form-label { color: #d1d5db; }

.form-error { font-size: 0.75rem; color: #ef4444; margin-top: 0.25rem; }

/* ---- Badge ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px; font-size: 0.75rem; font-weight: 600;
}
.badge-primary { background: #eff0ff; color: #6366f1; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.dark .badge-primary { background: #1e1b4b; color: #a5b4fc; }
.dark .badge-success { background: #052e16; color: #4ade80; }
.dark .badge-warning { background: #451a03; color: #fbbf24; }
.dark .badge-danger  { background: #450a0a; color: #f87171; }

/* ---- Skeleton Loading ---- */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: 0.375rem;
}
.dark .skeleton {
  background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
  background-size: 200% 100%;
}
@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Progress Bar ---- */
.progress-bar {
  height: 6px; background: #e5e7eb; border-radius: 9999px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  border-radius: 9999px;
  transition: width 0.4s ease;
}
.dark .progress-bar { background: #374151; }

/* ---- Quiz Option ---- */
.quiz-option {
  width: 100%; text-align: left;
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  border: 2px solid #e5e7eb;
  background: #ffffff;
  cursor: pointer; transition: all 0.18s ease;
  display: flex; align-items: flex-start; gap: 0.75rem;
  font-size: 0.9375rem; color: #1f2937;
}
.quiz-option:hover:not(:disabled) { border-color: #6366f1; background: #eff0ff; }
.quiz-option.selected { border-color: #6366f1; background: #eff0ff; color: #4f46e5; font-weight: 500; }
.quiz-option.correct  { border-color: #22c55e; background: #dcfce7; color: #15803d; }
.quiz-option.incorrect { border-color: #ef4444; background: #fee2e2; color: #b91c1c; }
.dark .quiz-option { background: #1f2937; border-color: #374151; color: #f3f4f6; }
.dark .quiz-option:hover:not(:disabled) { border-color: #818cf8; background: #1e1b4b; }
.dark .quiz-option.selected { border-color: #818cf8; background: #1e1b4b; color: #a5b4fc; }
.dark .quiz-option.correct  { border-color: #4ade80; background: #052e16; color: #4ade80; }
.dark .quiz-option.incorrect { border-color: #f87171; background: #450a0a; color: #f87171; }

/* ---- Difficulty Colors ---- */
.diff-easy   { color: #16a34a; background: #dcfce7; }
.diff-medium { color: #d97706; background: #fef3c7; }
.diff-hard   { color: #dc2626; background: #fee2e2; }
.dark .diff-easy   { color: #4ade80; background: #052e16; }
.dark .diff-medium { color: #fbbf24; background: #451a03; }
.dark .diff-hard   { color: #f87171; background: #450a0a; }

/* ---- Hero gradient ---- */
.hero-gradient {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 70%, #0f172a 100%);
}

/* ---- Glassmorphism card ---- */
.glass {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 1rem;
}

/* ---- Timer colors ---- */
.timer-ok      { color: #22c55e; }
.timer-warning { color: #f59e0b; animation: pulse 1s infinite; }
.timer-danger  { color: #ef4444; animation: pulse 0.5s infinite; }

/* ---- Answer key letter ---- */
.answer-letter {
  min-width: 2rem; min-height: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.5rem; font-weight: 700; font-size: 0.875rem;
  background: #e5e7eb; color: #6b7280;
  transition: all 0.2s;
}
.selected .answer-letter   { background: #6366f1; color: white; }
.correct .answer-letter    { background: #22c55e; color: white; }
.incorrect .answer-letter  { background: #ef4444; color: white; }

/* ---- Animate ---- */
.animate-fade-in { animation: fadeIn 0.12s ease-out; }
.animate-slide-up { animation: slideUp 0.4s ease-out; }

/* ---- Admin Tabs ---- */
.admin-tab {
  padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500;
  border-bottom: 2px solid transparent; color: #6b7280; cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.admin-tab.active { border-bottom-color: #6366f1; color: #6366f1; }
.dark .admin-tab { color: #9ca3af; }
.dark .admin-tab.active { color: #818cf8; border-bottom-color: #818cf8; }

/* ---- Table ---- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 0.625rem 1rem; text-align: left;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: #6b7280; background: #f9fafb; border-bottom: 1px solid #e5e7eb;
}
.data-table td {
  padding: 0.75rem 1rem; font-size: 0.875rem;
  border-bottom: 1px solid #f3f4f6; color: #374151;
}
.data-table tr:hover td { background: #f9fafb; }
.dark .data-table th { background: #1f2937; color: #9ca3af; border-color: #374151; }
.dark .data-table td { color: #d1d5db; border-color: #1f2937; }
.dark .data-table tr:hover td { background: #1f2937; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-box {
  background: white; border-radius: 1.25rem;
  width: 100%; max-width: 32rem; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.25);
  animation: slideUp 0.3s ease-out;
}
.dark .modal-box { background: #111827; border: 1px solid #1f2937; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .btn-primary, .btn-secondary { padding: 0.5rem 1rem; font-size: 0.8125rem; }
}

/* ── Page transition: fast, GPU-accelerated, no backdrop-blur ── */
#app > div {
  will-change: opacity;
}
#app > div[style*="display: none"] {
  will-change: auto;  /* free GPU when hidden */
}

/* Nav progress bar smooth animation */
#nav-progress {
  will-change: width, opacity;
  transform: translateZ(0);  /* promote to GPU layer */
}

/* Disable slow transitions on mobile for snappier feel */
@media (max-width: 768px) {
  .transition-all  { transition-duration: 100ms !important; }
  .transition      { transition-duration: 100ms !important; }
  .duration-200    { transition-duration: 100ms !important; }
  .duration-300    { transition-duration: 150ms !important; }
}
