:root {
  --ink: #1a1a2e;
  --muted: #6b7280;
  --paper: #ffffff;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --soft: #f8fafc;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --gradient-start: #f8fafc;
  --gradient-end: #e2e8f0;
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --paper: #1e293b;
  --line: #334155;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --soft: #0f172a;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --gradient-start: #0f172a;
  --gradient-end: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  min-height: 100vh;
}

.exam-body {
  padding-top: 80px;
}

/* Sticky Header */
.sticky-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

[data-theme="dark"] .sticky-header {
  background: var(--paper);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Dark Mode Toggle */
.theme-toggle {
  background: none;
  border: 2px solid var(--line);
  border-radius: 50px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
  transition: all 0.3s ease;
  min-width: 70px;
  justify-content: center;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--soft);
}

.theme-icon {
  font-size: 16px;
}

/* Mobile Responsive Improvements */
@media (max-width: 768px) {
  .sticky-header {
    position: sticky;
    padding: 8px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .header-left {
    min-width: 200px;
  }
  
  .header-controls {
    gap: 8px;
  }
  
  .theme-toggle {
    padding: 6px 8px;
    min-width: 50px;
    font-size: 12px;
  }
  
  .exam-body {
    padding-top: 16px;
  }
  
  .category-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  
  .question-card {
    margin: 12px 0;
    padding: 16px;
  }
  
  .question-options {
    gap: 8px;
  }
  
  .option-card {
    padding: 12px 16px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .sticky-header {
    padding: 6px 12px;
  }
  
  .header-left h3 {
    font-size: 16px;
  }
  
  .timer-display {
    font-size: 18px !important;
  }
  
  .exam-container {
    padding: 16px !important;
  }
  
  .question-card {
    padding: 12px;
  }
}

.header-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.change-exam-link {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.2s ease;
}

.change-exam-link:hover {
  color: var(--accent);
}

.header-info {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.sticky-header .header-sub {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 20px;
}

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

.header-logo {
  width: 40px;
  height: 40px;
  filter: none;
  transition: transform 0.3s ease;
}

.header-logo:hover {
  transform: rotate(30deg) scale(1.1);
}

.header-title {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.timer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 20px;
  background: var(--soft);
  border-radius: 12px;
  border: 1px solid var(--line);
  transition: all 0.3s ease;
}

.timer-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 2px;
}

[data-theme="dark"] .change-exam-link {
  color: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .change-exam-link:hover {
  color: #fff;
}

[data-theme="dark"] .sticky-header .header-sub {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .header-logo {
  filter: brightness(0) invert(1);
}

[data-theme="dark"] .header-title {
  color: #fff;
}

[data-theme="dark"] .timer-box {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .timer-label {
  color: rgba(255, 255, 255, 0.7);
}

.timer-value {
  font-size: 22px;
  font-weight: 700;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  color: #4ade80;
  text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.timer-box.timer-active {
  background: rgba(220, 38, 38, 0.2);
  border-color: rgba(220, 38, 38, 0.5);
  animation: timer-pulse 1s ease-in-out infinite;
}

.timer-box.timer-active .timer-value {
  color: #ef4444;
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.7);
}

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

/* Timer Ended State */
.timer-box.timer-ended {
  background: rgba(100, 100, 100, 0.2);
  border-color: rgba(100, 100, 100, 0.3);
  animation: none;
}

.timer-box.timer-ended .timer-value {
  color: #9ca3af;
  text-shadow: none;
}

/* Exam Collapse Animation */
.exam-collapsed {
  animation: collapse-exam 0.5s ease-out forwards;
}

@keyframes collapse-exam {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.95); }
}

/* Exam Ended Message */
.exam-ended-message {
  text-align: center;
  padding: 60px 40px;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  border-radius: 16px;
  border: 2px solid var(--line);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.exam-ended-message .ended-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: bounce-icon 2s ease-in-out infinite;
}

@keyframes bounce-icon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.exam-ended-message h2 {
  font-size: 28px;
  color: var(--ink);
  margin: 0 0 16px 0;
}

.exam-ended-message p {
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 8px 0;
}

.exam-ended-message .ended-note {
  font-size: 14px;
  color: #9ca3af;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
}

/* Main Content */
.exam-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

h1 {
  text-align: center;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.home-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  max-width: 720px;
  margin: 24px auto 0;
}

.link-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.panel {
  background: var(--paper);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  margin-bottom: 24px;
  transition: box-shadow 0.3s ease;
}

.panel:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 20px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.student-panel {
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  scroll-margin-top: 120px;
}

.student-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.instructions-box {
  padding: 12px 16px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 8px;
  font-size: 14px;
  color: #92400e;
  border-left: 4px solid var(--warning);
}

.exam-header .header-row {
  display: none;
}

.header-title { font-weight: bold; font-size: 18px; }
.header-sub { color: var(--muted); font-size: 14px; }

.header-box {
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 6px;
  min-width: 240px;
  background: #fff;
  display: grid;
  gap: 6px;
}

.header-box input { width: 100%; }
.timer-box { font-weight: bold; }

/* Responsive Design */
@media (max-width: 768px) {
  .sticky-header {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }
  
  .header-left, .header-center, .header-right {
    flex: none;
    width: 100%;
    justify-content: center;
  }
  
  .header-info {
    justify-content: center;
  }
  
  .exam-body {
    padding-top: 180px;
  }
  
  .student-form {
    grid-template-columns: 1fr;
  }
  
  .exam-main {
    padding: 20px 16px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .student-panel {
    margin-top: 8px;
    scroll-margin-top: 200px;
  }
}

.login-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  grid-column: 1 / -1;
  margin-top: 8px;
}

.login-actions button {
  flex: 1;
  max-width: 200px;
}

.quiz-hero {
  border: 2px solid #0f172a;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

.quiz-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: start;
}

.quiz-board #quiz-container {
  margin-top: 8px;
}

.quiz-leaderboard {
  position: sticky;
  top: 20px;
}

.leaderboard-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
}

.leaderboard-item:nth-child(1) {
  border: 2px solid #f59e0b;
  background: #fff7ed;
}

.leaderboard-rank {
  font-weight: 700;
}

.leaderboard-name {
  color: var(--muted);
}

.leaderboard-score {
  font-weight: 700;
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  animation: confetti-fall 3s linear infinite;
}

@keyframes confetti-fall {
  0% { transform: translateY(-10vh) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(360deg); }
}

.form-row { display: grid; gap: 6px; margin-bottom: 10px; }

input {
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
  background: var(--paper);
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input:disabled {
  background: var(--soft);
  cursor: not-allowed;
}

button {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--paper);
  color: var(--accent);
  border: 2px solid var(--accent);
}

.btn-secondary:hover {
  background: var(--accent);
  color: #fff;
}

.btn-submit {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  background: linear-gradient(135deg, var(--success) 0%, #047857 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3);
}

.btn-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.4);
}

.btn-submit:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.link-btn {
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: #fff;
  color: var(--accent);
  text-decoration: none;
  display: inline-block;
}

.controls label {
  font-size: 12px;
  color: var(--muted);
}

.status {
  margin-top: 12px;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 8px;
  display: inline-block;
  font-weight: 500;
}

.status-info {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  border-left: 4px solid var(--accent);
}

.status-success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
  border-left: 4px solid var(--success);
}

.status-error {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
  border-left: 4px solid var(--danger);
}

.exam-sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 20px 24px;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.questions-container {
  margin-bottom: 24px;
}

.question {
  padding: 20px;
  border-bottom: none;
  margin-bottom: 16px;
  background: var(--paper);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.question:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.1);
}

.question:last-child { margin-bottom: 0; }

.q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.q-number {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
}

.q-marks {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: var(--soft);
  padding: 4px 10px;
  border-radius: 20px;
}

.q-text {
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.6;
}

.q-figure {
  margin: 8px 0 10px 0;
  padding: 6px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-block;
}

.q-figure img { max-width: 220px; max-height: 220px; }

.options {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.option-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--soft);
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.option-row:hover {
  background: rgba(37, 99, 235, 0.05);
  border-color: rgba(37, 99, 235, 0.2);
}

.option-label {
  font-weight: 700;
  color: var(--accent);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border-radius: 50%;
  font-size: 12px;
}

.option-content img {
  display: block;
  margin-top: 4px;
  max-width: 220px;
  max-height: 220px;
}

.question.unanswered {
  border: 2px solid var(--danger);
  background: linear-gradient(135deg, #fff 0%, #fef2f2 100%);
}

.question .unanswered-note {
  color: var(--danger);
  font-weight: 600;
  margin-top: 8px;
  font-size: 13px;
}

.submit-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px dashed var(--line);
}

/* Admin styles */
.table-wrap { overflow-x: auto; }

.score-low {
  color: #c0392b;
  font-weight: 700;
}

.score-mid {
  color: #d4ac0d;
  font-weight: 700;
}

.score-high {
  color: #1e8449;
  font-weight: 700;
}

.log-details {
  font-size: 12px;
  color: var(--muted);
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
}

.portal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.portal-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.portal-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-family: Arial, sans-serif;
  font-size: 14px;
}

table th, table td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

table th { background: #f0f2f5; }

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.detail-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-top: 12px;
  font-family: Arial, sans-serif;
}

.answer-item {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

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

.answer-meta { color: #555; font-size: 14px; }

.answer-selected { color: #0f766e; font-weight: bold; }

.solution-block {
  margin-top: 6px;
  padding: 6px;
  border-left: 3px solid #0f172a;
  background: #f9fafb;
}

/* ========================================
   LANDING PAGE STYLES
   ======================================== */

.landing-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.landing-container {
  max-width: 1200px;
  width: 100%;
}

.landing-header {
  text-align: center;
  margin-bottom: 48px;
}

.landing-logo {
  width: 80px;
  height: 80px;
  filter: brightness(0) invert(1);
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.landing-title {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 12px 0;
  letter-spacing: -0.5px;
}

.landing-subtitle {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}

.selector-title {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  margin: 0 0 32px 0;
}

.exam-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.exam-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  text-decoration: none;
  color: #fff;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.exam-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-color);
}

.exam-card:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--card-color);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.see-card { --card-color: #059669; }
.cee-card { --card-color: #dc2626; }
.ioe-card { --card-color: #2563eb; }

.card-icon {
  font-size: 48px;
  flex-shrink: 0;
}

.card-content {
  flex: 1;
}

.card-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--card-color);
}

.card-level {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 4px 0;
}

.card-name {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0 0 12px 0;
}

.card-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.subject-tag {
  font-size: 11px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.8);
}

.card-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

.card-arrow {
  font-size: 24px;
  color: var(--card-color);
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.3s ease;
}

.exam-card:hover .card-arrow {
  opacity: 1;
  transform: translateX(0);
}

.landing-footer {
  text-align: center;
  margin-top: 48px;
}

.admin-link {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.admin-link:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
}

/* Category badge in header */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.category-badge.see { background: rgba(5, 150, 105, 0.2); color: #34d399; }
.category-badge.cee { background: rgba(220, 38, 38, 0.2); color: #f87171; }
.category-badge.ioe { background: rgba(37, 99, 235, 0.2); color: #60a5fa; }
.category-badge.custom { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--soft);
  padding: 4px;
  border-radius: 12px;
}

.admin-tab {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.admin-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
}

.admin-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.admin-tab.see.active { color: #059669; border-bottom: 3px solid #059669; }
.admin-tab.cee.active { color: #dc2626; border-bottom: 3px solid #dc2626; }
.admin-tab.ioe.active { color: #2563eb; border-bottom: 3px solid #2563eb; }

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Admin Header */
.admin-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.admin-header h1 {
  margin: 0;
  font-size: 24px;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.back-link:hover {
  background: var(--soft);
  color: var(--ink);
}

/* Exam Control Grid */
.exam-control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.control-card {
  background: var(--soft);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.control-label {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.control-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

@media print {
  body * { visibility: hidden; }
  #attempt-detail, #attempt-detail * { visibility: visible; }
  #attempt-detail { position: absolute; left: 0; top: 0; width: 100%; }
}


@media (max-width: 768px) {
  .landing-title {
    font-size: 28px;
  }
  
  .exam-cards {
    grid-template-columns: 1fr;
  }
  
  .exam-card {
    flex-direction: column;
    text-align: center;
  }
  
  .card-subjects {
    justify-content: center;
  }
  
  .card-meta {
    justify-content: center;
  }
  
  .card-arrow {
    display: none;
  }
}

/* ==================== Custom Exam Builder ==================== */
.custom-exam-form {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.custom-exam-form h3 {
  margin: 0 0 16px;
  color: var(--ink);
}

.custom-exam-form h4 {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  margin-bottom: 16px;
}

.form-grid-2col .form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-grid-2col label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.question-search-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.question-search-bar input,
.question-search-bar select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

.question-search-bar input { flex: 1; min-width: 140px; }
.question-search-bar select { min-width: 120px; }

.ce-search-results {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 16px;
}

.ce-search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}

.ce-search-item:last-child { border-bottom: none; }

.ce-search-item.ce-already-added {
  opacity: 0.5;
}

.ce-q-info {
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ce-selected-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.ce-selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ce-q-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.ce-q-tag button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

.ce-q-tag button:hover { color: #fff; }

/* Custom exam cards list */
.ce-exam-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ce-exam-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  transition: box-shadow 0.2s;
}

.ce-exam-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.ce-exam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ce-exam-header strong {
  font-size: 16px;
}

.ce-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  margin-left: 8px;
  vertical-align: middle;
}

.ce-status-active { color: var(--success); font-weight: 600; font-size: 13px; }
.ce-status-inactive { color: var(--muted); font-size: 13px; }

.ce-exam-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.ce-exam-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-small {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-small.btn-accent {
  background: var(--accent);
  color: #fff;
}

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

.btn-small.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn-small.btn-secondary {
  background: var(--line);
  color: var(--ink);
}

.btn-small.btn-secondary:hover { background: #d1d5db; }

.btn-small.btn-disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: default;
}

/* Custom exam attempts table */
.ce-attempts-panel { margin-top: 12px; }
.ce-attempts-panel h4 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.ce-attempts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ce-attempts-table th,
.ce-attempts-table td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.ce-attempts-table th {
  background: var(--soft);
  font-weight: 600;
}

@media (max-width: 768px) {
  .form-grid-2col { grid-template-columns: 1fr; }
  .ce-exam-header { flex-direction: column; gap: 4px; align-items: flex-start; }
}

/* ========================================
   UX IMPROVEMENTS
   ======================================== */

/* Progress Indicators */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 1001;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981, #f59e0b);
  transition: width 0.3s ease;
  width: 0%;
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 3px solid #fff;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.exam-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.progress-text {
  font-weight: 500;
}

/* Enhanced Error Messages */
.error-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fca5a5;
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  color: #991b1b;
  font-weight: 500;
  margin: 16px 0;
  animation: slideIn 0.3s ease-out;
}

.error-icon {
  font-size: 20px;
  color: var(--danger);
  flex-shrink: 0;
}

.success-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-left: 4px solid var(--success);
  border-radius: 8px;
  color: #166534;
  font-weight: 500;
  margin: 16px 0;
  animation: slideIn 0.3s ease-out;
}

.success-icon {
  font-size: 20px;
  color: var(--success);
  flex-shrink: 0;
}

.warning-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  color: #92400e;
  font-weight: 500;
  margin: 16px 0;
  animation: slideIn 0.3s ease-out;
}

.warning-icon {
  font-size: 20px;
  color: var(--warning);
  flex-shrink: 0;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 100px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.toast {
  padding: 16px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(400px);
  animation: toastSlideIn 0.3s ease-out forwards;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.toast.success {
  background: linear-gradient(135deg, var(--success) 0%, #047857 100%);
}

.toast.error {
  background: linear-gradient(135deg, var(--danger) 0%, #991b1b 100%);
}

.toast.warning {
  background: linear-gradient(135deg, var(--warning) 0%, #92400e 100%);
}

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes toastSlideIn {
  to {
    transform: translateX(0);
  }
}

/* Connection Status Indicator */
.connection-status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  z-index: 1000;
  transition: all 0.3s ease;
}

.connection-status.online {
  background: rgba(16, 185, 129, 0.9);
  color: white;
}

.connection-status.offline {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  animation: pulse 1s infinite;
}

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

/* Dark mode specific adjustments */
[data-theme="dark"] .error-message {
  background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
  border-color: #991b1b;
  color: #fca5a5;
}

[data-theme="dark"] .success-message {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
  border-color: #059669;
  color: #6ee7b7;
}

[data-theme="dark"] .warning-message {
  background: linear-gradient(135deg, #451a03 0%, #92400e 100%);
  border-color: #d97706;
  color: #fcd34d;
}

/* Additional Mobile Responsiveness */
@media (max-width: 768px) {
  .toast-container {
    top: 120px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .connection-status {
    bottom: 10px;
    right: 10px;
    font-size: 11px;
    padding: 6px 10px;
  }
  
  .error-message, .success-message, .warning-message {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .progress-container {
    height: 4px;
  }
  
  .student-panel {
    margin: 8px;
    padding: 16px;
  }
  
  .panel-title {
    font-size: 16px;
  }
  
  .question {
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .q-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .q-number, .q-marks {
    font-size: 12px;
  }
  
  .options {
    gap: 8px;
  }
  
  .option-row {
    padding: 8px 12px;
    font-size: 14px;
  }
  
  .btn-submit {
    font-size: 18px;
    padding: 18px;
  }
}

@media (max-width: 480px) {
  .header-left .header-info {
    flex-direction: column;
    gap: 4px;
  }
  
  .category-badge {
    font-size: 11px;
    padding: 4px 10px;
  }
  
  .header-sub {
    font-size: 11px;
  }
  
  .student-form {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .login-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .login-actions button {
    max-width: none;
  }
}

/* Answered question styling */
.question.answered {
  border-color: var(--success);
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

[data-theme="dark"] .question.answered {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
}
