/* Modern Aviation Dark Theme for Question Bank */
:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: #162032;
  --bg-card-hover: #1c2942;
  --bg-input: #1a2438;
  --border-color: #26354f;
  --border-focus: #3b82f6;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-blue: #2563eb;
  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;

  --sidebar-width: 250px;
  --navbar-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Utility Layouts */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  text-decoration: none;
  user-select: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), #1d4ed8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.5);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}
.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
}
.btn-success:hover {
  background: linear-gradient(135deg, #10b981, #34d399);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.btn-danger:hover {
  background: var(--accent-red);
  color: white;
}
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-admin {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
}
.badge-student {
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.3);
}
.badge-verified {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-unverified {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-diff-easy {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
}
.badge-diff-medium {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
}
.badge-diff-hard {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.1rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ================= AUTH VIEW ================= */
#auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 50% 20%, #172554 0%, #0b0f19 75%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(22, 32, 50, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}
.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.4rem;
}

.auth-tabs {
  display: flex;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}
.auth-tab-btn {
  flex: 1;
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.auth-tab-btn.active {
  background: var(--accent-blue);
  color: white;
}

.demo-login-box {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border-color);
}
.demo-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-align: center;
}
.demo-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ================= APP LAYOUT ================= */
#app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Navbar */
.navbar {
  height: var(--navbar-height);
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 40;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
}
.nav-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
}
.user-avatar {
  width: 26px;
  height: 26px;
  background: var(--accent-blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Main Container with Sidebar */
.app-body {
  display: flex;
  flex: 1;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(37, 99, 235, 0.18);
  color: #93c5fd;
  border-left: 3px solid var(--accent-blue);
}
.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem 0.25rem;
}

.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
}
.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 600;
}
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}
.stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Content Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.category-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.category-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}
.category-card.selected {
  border-color: var(--accent-blue);
  background: rgba(37, 99, 235, 0.12);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.3);
}

/* ================= QUIZ INTERFACE ================= */
.quiz-container {
  max-width: 860px;
  margin: 0 auto;
}
.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.25rem;
}
.quiz-timer {
  font-family: monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: var(--bg-input);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* Question Palette */
.palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.palette-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.palette-btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}
.palette-btn.active {
  background: var(--accent-blue);
  color: white;
  border-color: #60a5fa;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}
.palette-btn.answered {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
}
.palette-btn.flagged {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

/* Question Box */
.question-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}
.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
  margin-bottom: 1.75rem;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.option-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.option-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
}
.option-item.selected {
  background: rgba(37, 99, 235, 0.15);
  border-color: var(--accent-blue);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.2);
}
.option-item.correct {
  background: rgba(16, 185, 129, 0.18) !important;
  border-color: var(--accent-green) !important;
  color: #6ee7b7;
}
.option-item.incorrect {
  background: rgba(239, 68, 68, 0.18) !important;
  border-color: var(--accent-red) !important;
  color: #fca5a5;
}
.option-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-input);
  flex-shrink: 0;
}
.option-item.selected .option-marker {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}
.option-item.correct .option-marker {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
}
.option-item.incorrect .option-marker {
  background: var(--accent-red);
  color: white;
  border-color: var(--accent-red);
}
.option-text {
  font-size: 1rem;
  flex: 1;
}

/* Explanation Box */
.explanation-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.8);
  border-left: 4px solid var(--accent-blue);
  border-radius: var(--radius-md);
}
.explanation-box.correct {
  border-left-color: var(--accent-green);
  background: rgba(6, 78, 59, 0.2);
}
.explanation-box.incorrect {
  border-left-color: var(--accent-red);
  background: rgba(127, 29, 29, 0.2);
}

/* ================= FLASHCARDS ================= */
.flashcard-wrapper {
  perspective: 1000px;
  max-width: 650px;
  margin: 2rem auto;
  min-height: 360px;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 360px;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}
.flashcard-inner.flipped {
  transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  min-height: 360px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}
.flashcard-front {
  background: linear-gradient(145deg, #162032, #0f172a);
}
.flashcard-back {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  transform: rotateY(180deg);
}

/* ================= TABLES ================= */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}
.data-table th {
  background: var(--bg-secondary);
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}
.data-table tr:hover td {
  background: var(--bg-card-hover);
}

/* ================= MODALS ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

/* ================= TOASTS ================= */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 200;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.2s ease-out;
}
.toast-success { border-left: 4px solid var(--accent-green); }
.toast-error { border-left: 4px solid var(--accent-red); }
.toast-info { border-left: 4px solid var(--accent-blue); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 768px) {
  .app-body {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .nav-section-title {
    display: none;
  }
  .main-content {
    padding: 1rem;
  }
}

