/* ========================================
   EXAM SYSTEM — Mobile-First Design System
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* CSS Variables */
:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --primary-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  --accent: #7C3AED;
  --success: #10B981;
  --success-light: #D1FAE5;
  --success-dark: #059669;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --error: #EF4444;
  --error-light: #FEE2E2;
  --error-dark: #DC2626;
  --white: #FFFFFF;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;
  --bg: #F0F2F5;
  --surface: #FFFFFF;
  --text: #1E293B;
  --text-secondary: #64748B;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 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);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --navbar-h: 56px;
}

/* ========================================
   RESET
   ======================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; }
ul { list-style: none; }
.hidden { display: none !important; }

/* ========================================
   NAVBAR — Hamburger on mobile
   ======================================== */
.navbar {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #1a1a3e 100%);
  padding: 0 16px;
  height: var(--navbar-h);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.navbar-brand:hover { color: #A5B4FC; }

/* Hamburger toggle */
.nav-toggle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  z-index: 1001;
  background: none;
  border: none;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: var(--transition);
}
.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

.navbar-links {
  position: fixed;
  top: var(--navbar-h);
  right: -100%;
  width: 260px;
  height: calc(100vh - var(--navbar-h));
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  transition: right 0.3s ease;
  z-index: 899;
  overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}
.navbar-links.open { right: 0; }
.navbar-links a {
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 14px 24px;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.navbar-links a:hover,
.navbar-links a.active {
  background: rgba(79,70,229,0.2);
  color: #A5B4FC;
  border-left-color: var(--primary);
}
.navbar-profile {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  padding: 14px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: auto;
}
.nav-overlay {
  display: none;
  position: fixed;
  top: var(--navbar-h);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--navbar-h));
  background: rgba(0,0,0,0.4);
  z-index: 898;
}
.nav-overlay.show { display: block; }

/* ========================================
   LAYOUT — Full-width, no constriction
   ======================================== */
.page-wrap {
  padding: 12px;
  width: 100%;
}
.page-wrap h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.page-wrap h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ========================================
   CARDS
   ======================================== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 12px;
}
.card h2, .card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ========================================
   MESSAGES
   ======================================== */
.message {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  animation: slideDown 0.3s ease;
  transition: opacity 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.success { background: var(--success-light); color: var(--success-dark); border: 1px solid var(--success); }
.message.error { background: var(--error-light); color: var(--error-dark); border: 1px solid var(--error); }
.error-message { color: var(--error-dark); background: var(--error-light); border: 1px solid rgba(239,68,68,0.3); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px; text-align: center; font-size: 0.85rem; }
.success-message { color: var(--success-dark); background: var(--success-light); border: 1px solid rgba(16,185,129,0.3); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px; text-align: center; font-size: 0.85rem; }
.answer-message { color: var(--error-dark); background: var(--error-light); border: 1px solid rgba(239,68,68,0.3); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px; text-align: center; font-size: 0.85rem; }
.explanation-message { margin-top: 12px; padding: 14px 16px; background: var(--primary-light); border: 1px solid rgba(79,70,229,0.2); border-radius: var(--radius); font-size: 0.85rem; color: var(--gray-700); }

/* ========================================
   FORMS
   ======================================== */
.form-container {
  background: var(--gray-50);
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.form-group { margin-bottom: 16px; }
label {
  display: block;
  margin-bottom: 6px;
  color: var(--gray-700);
  font-weight: 600;
  font-size: 0.85rem;
}
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="tel"], input[type="url"],
input[type="search"], textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: var(--transition);
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
input::placeholder, textarea::placeholder { color: var(--gray-400); }
select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8.825a.5.5 0 01-.354-.146l-4-4a.5.5 0 11.708-.708L6 7.618l3.646-3.647a.5.5 0 11.708.708l-4 4A.5.5 0 016 8.825z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
textarea { resize: vertical; min-height: 80px; }
input[type="radio"] { width: auto; margin-right: 8px; accent-color: var(--primary); cursor: pointer; }
input[type="checkbox"] { accent-color: var(--primary); cursor: pointer; }
.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
.full-width { grid-column: 1 / -1; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ========================================
   BUTTONS
   ======================================== */
.button, button, .toggle-btn, .update-btn, #showFormBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--white);
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.5;
  min-height: 44px; /* Touch target */
}
#showFormBtn { margin-bottom: 16px; }
.button:hover, button:hover, .toggle-btn:hover, .update-btn:hover, #showFormBtn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  color: var(--white);
}
.button:active, button:active { transform: translateY(0); }
.button:disabled, button:disabled {
  background: var(--gray-300);
  color: var(--gray-500);
  cursor: not-allowed;
  transform: none;
}
.delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--error);
  color: var(--white);
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  min-height: 44px;
}
.delete-btn:hover { background: var(--error-dark); }

/* ========================================
   TABLES — Responsive horizontal scroll
   ======================================== */
.table-container {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: 60vh;
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.8rem;
}
th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th:hover { background: var(--gray-100); }
td {
  color: var(--text-secondary);
  border-bottom: 1px solid var(--gray-100);
}
tr:hover td { background: var(--gray-50); }
tr:last-child td { border-bottom: none; }
td textarea, td input, td select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: inherit;
  transition: var(--transition);
  background: var(--white);
  color: var(--text);
}
td textarea:focus, td input:focus, td select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
  outline: none;
}
td textarea { min-height: 60px; resize: vertical; }
.sort-icon { display: inline-block; margin-left: 4px; vertical-align: middle; font-size: 0.7rem; opacity: 0.4; }
.sort-asc { border-bottom: 5px solid var(--primary); border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: none; opacity: 1; }
.sort-desc { border-top: 5px solid var(--primary); border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: none; opacity: 1; }

/* ========================================
   FILTERS
   ======================================== */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters input, .filters select {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
  flex: 1;
  min-width: 0;
  transition: var(--transition);
  background: var(--white);
}
.filters input:focus, .filters select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
  outline: none;
}
.filters label {
  margin-right: 4px;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ========================================
   ATTEND EXAM — Full-screen mobile layout
   ======================================== */

/* Exam app shell — no wasted space */
.exam-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

/* Top bar: timer + exam info */
.exam-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #0F172A, #1E293B);
  color: var(--white);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.exam-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.exam-topbar .exam-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exam-topbar .timer-badge {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #FCA5A5;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  animation: pulse-glow 2s infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.2); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
.exam-topbar .user-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--white);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.exam-topbar .user-btn:hover { background: rgba(255,255,255,0.2); }

/* Question area — takes all available space */
.exam-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Question card */
.question-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px 16px;
  max-width: 800px;
  margin: 0 auto;
}
.question-card .q-number {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 14px;
}
.question-card .q-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 20px;
  white-space: pre-line;
  text-align: justify;
}

/* Option cards — touch-friendly */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gray-50);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  color: var(--text);
  min-height: 48px;
}
.option-item:hover { border-color: var(--primary); background: var(--primary-light); }
.option-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.option-item input[type="radio"] { margin-top: 2px; flex-shrink: 0; }
.option-item .opt-label { font-weight: 600; color: var(--primary); margin-right: 4px; }

/* Prev/Next — sticky bottom on mobile */
.exam-nav {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.exam-nav .button { flex: 1; justify-content: center; }

/* Question grid drawer (bottom sheet) */
.q-drawer-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: var(--white);
  border: none;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(79,70,229,0.4);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-drawer-toggle:hover { transform: scale(1.08); }

.q-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
}
.q-drawer-overlay.show { display: block; }

.q-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px 16px 32px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 301;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
}
.q-drawer.open { transform: translateY(0); }
.q-drawer-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-300);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.q-drawer h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 14px;
  text-align: center;
  color: var(--text);
}

/* Question nav buttons */
.question-navigation {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
}
.nav-button {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--gray-100);
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  transition: var(--transition);
  border: 2px solid transparent;
  min-height: 44px;
}
.nav-button:hover { background: var(--gray-200); color: var(--text); }
.nav-button.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.nav-button.answered {
  background: var(--success);
  color: var(--white);
  border-color: var(--success);
}
.nav-button.answered:hover { background: var(--success-dark); }

/* Profile slide-out panel */
.profile-panel {
  position: fixed;
  top: 0;
  left: -300px;
  width: 280px;
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  z-index: 400;
  transition: left 0.3s ease;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  overflow-y: auto;
  padding: 20px;
}
.profile-panel.open { left: 0; }
.profile-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 399;
}
.profile-panel-overlay.show { display: block; }
.profile-panel h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.profile-panel p {
  margin: 8px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.profile-panel p strong { color: var(--text); font-weight: 600; }
.profile-panel a {
  display: block;
  color: var(--primary);
  font-weight: 500;
  font-size: 0.85rem;
  padding: 8px 0;
}
.profile-panel .close-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--gray-500);
  cursor: pointer;
  padding: 4px;
  min-height: auto;
}

/* Exam list view (inside attend_exam when no exam selected) */
.exam-list-section { margin-bottom: 20px; }
.exam-list-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Submit exam button */
.submit-exam-wrap {
  text-align: center;
  padding: 16px;
}
.submit-exam-wrap button {
  background: var(--error);
  font-size: 1rem;
  padding: 14px 32px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  width: 100%;
  max-width: 320px;
}
.submit-exam-wrap button:hover { background: var(--error-dark); }

/* Result view */
.result-header {
  background: var(--primary-light);
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  text-align: center;
}
.result-header h2 {
  color: var(--primary);
  margin-bottom: 8px;
}
.result-header .score-big {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}
.result-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
}
.result-question h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
}
.result-question .r-options {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}
.result-question .r-options li {
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
}
.result-question .r-options li.correct {
  background: var(--success-light);
  border: 1px solid var(--success);
  font-weight: 600;
}
.result-question .r-options li.incorrect {
  background: var(--error-light);
  border: 1px solid var(--error);
}

/* Pagination */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 16px 0;
}
.pagination .button {
  padding: 8px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius);
  min-width: 40px;
  min-height: 40px;
}
.pagination .button.active {
  background: var(--primary-hover);
  cursor: default;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}

.navigation-buttons {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}

.back-link {
  margin-top: 16px;
  text-align: center;
}

/* ========================================
   DAILY QUESTION
   ======================================== */
.daily-question {
  background: var(--white);
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.daily-question h2 { color: var(--text); margin-bottom: 14px; }
.daily-question .form-group { margin-bottom: 12px; }
.daily-question label {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  font-weight: 400;
  color: var(--text);
  padding: 12px 14px;
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  min-height: 44px;
}
.daily-question label:hover { border-color: var(--primary); background: var(--primary-light); }
.daily-question input[type="radio"] { margin-right: 10px; }

/* ========================================
   TRIAL USER
   ======================================== */
.trial-user-content {
  margin-top: 16px;
  padding: 16px;
  border: 2px dashed var(--warning);
  border-radius: var(--radius-lg);
  background: var(--warning-light);
  text-align: center;
}
.trial-user-content h3 { color: var(--gray-800); margin-bottom: 10px; }
.trial-user-content p { color: var(--gray-600); font-size: 0.85rem; line-height: 1.6; margin-bottom: 12px; }
.qr-code { max-width: 140px; margin: 10px auto; display: block; border-radius: var(--radius); }
.whatsapp-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #25D366;
  color: var(--white);
  border-radius: var(--radius-full);
  margin-top: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
}
.whatsapp-button:hover { background: #128C7E; color: var(--white); }

/* ========================================
   SUBJECT SELECTION
   ======================================== */
.subject-selection {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.subject-selection label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}
.subject-selection label:hover { border-color: var(--primary); color: var(--primary); }

/* ========================================
   COMMENT FORM
   ======================================== */
.comment-form textarea {
  width: 100%;
  min-height: 70px;
  margin-bottom: 8px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.85rem;
}
.comment-form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); outline: none; }
.comment-form button {
  padding: 8px 16px;
  background: var(--success);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}
.comment-form button:hover { background: var(--success-dark); }
.comment-text {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ========================================
   TOOLTIP
   ======================================== */
.tooltip { position: relative; cursor: pointer; color: var(--primary); font-weight: 500; font-size: 0.85rem; }
.tooltip:hover .tooltip-text { visibility: visible; opacity: 1; }
.tooltip-text {
  visibility: hidden;
  opacity: 0;
  background: var(--gray-900);
  color: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius);
  position: absolute;
  z-index: 10;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  font-size: 0.8rem;
  line-height: 1.5;
  transition: var(--transition);
  box-shadow: var(--shadow-lg);
}

/* ========================================
   CURRENT TIME
   ======================================== */
.current-time {
  background: var(--primary-light);
  border: 1px solid rgba(79,70,229,0.15);
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--primary-hover);
  font-weight: 500;
}

/* ========================================
   USERNAME FEEDBACK
   ======================================== */
.username-feedback {
  font-size: 0.75rem;
  margin-top: 4px;
  display: block;
  font-weight: 500;
}
.username-feedback.available { color: var(--success); }
.username-feedback.taken, .username-feedback.error { color: var(--error); }

/* ========================================
   FORGOT PASSWORD
   ======================================== */
.forgot-password, .back-to-login {
  text-align: center;
  margin-top: 12px;
}
.forgot-password a, .back-to-login a {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ========================================
   EXAM SELECTOR
   ======================================== */
.exam-selector { margin-bottom: 16px; }

/* ========================================
   LINKS
   ======================================== */
.links {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.links h2 { font-size: 0.95rem; margin-bottom: 6px; }
.links a { font-size: 0.85rem; font-weight: 500; padding: 4px 0; }
.links ul { display: flex; flex-direction: column; gap: 4px; }

/* ========================================
   LOGIN PAGE — Split Layout
   ======================================== */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 40%, #1a1a3e 100%);
  padding: 16px;
}

/* On mobile, wrappers are transparent — children flow naturally */
.login-left, .login-right { display: contents; }

/* Brand */
.login-brand {
  text-align: center;
  padding: 20px 0 12px;
}
.login-logo {
  width: 52px;
  height: 52px;
  background: var(--primary-gradient);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
}
.login-logo span {
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
  line-height: 1;
}
.login-brand h1 {
  color: #FFFFFF;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}
.login-brand p {
  color: rgba(255,255,255,0.45);
  font-size: 0.85rem;
  line-height: 1.5;
}
.login-footer {
  color: rgba(255,255,255,0.2);
  font-size: 0.72rem;
  text-align: center;
  padding: 16px 0;
  display: none;
}

/* Card icon */
.card-icon {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1;
}

/* Login cards — dark glassmorphism */
.login-page .card {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 22px;
  margin-bottom: 16px;
}
.login-page .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.login-page .card h2 {
  text-align: center;
  color: #A5B4FC;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}
.login-page .card h3 {
  color: #C4B5FD;
  text-align: center;
  font-size: 0.95rem;
  margin-bottom: 10px;
}
.login-page .card label { color: rgba(255,255,255,0.7); }
.login-page .card input[type="text"],
.login-page .card input[type="password"],
.login-page .card input[type="email"],
.login-page .card select {
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.12);
  color: #E2E8F0;
}
.login-page .card input:focus, .login-page .card select:focus {
  border-color: #818CF8;
  box-shadow: 0 0 0 3px rgba(129,140,248,0.2);
}
.login-page .card input::placeholder { color: rgba(255,255,255,0.3); }
.login-page .card button[type="submit"] {
  background: var(--primary-gradient);
  width: 100%;
  height: 46px;
  font-weight: 700;
  border-radius: var(--radius);
  border: none;
  color: white;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
}
.login-page .card button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79,70,229,0.4);
}

/* Login form links */
.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}
.login-links a, .login-page .back-to-login a {
  color: #818CF8;
  font-size: 0.82rem;
  font-weight: 500;
}
.login-links a:hover, .login-page .back-to-login a:hover { color: #A5B4FC; }

/* Daily question option cards */
.dq-question {
  color: #E2E8F0;
  font-size: 0.88rem;
  line-height: 1.6;
  text-align: justify;
  white-space: pre-line;
  margin-bottom: 8px;
}
.dq-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.dq-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  color: #CBD5E1;
  font-size: 0.85rem;
  margin: 0;
  font-weight: 400;
}
.dq-option:hover {
  border-color: #818CF8;
  background: rgba(79,70,229,0.1);
}
.dq-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.dq-option:has(input:checked) {
  border-color: #818CF8;
  background: rgba(79,70,229,0.15);
}
.dq-option:has(input:checked) .dq-letter {
  background: var(--primary-gradient);
  border-color: transparent;
  color: white;
}
.dq-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #A5B4FC;
  flex-shrink: 0;
  transition: var(--transition);
}
.dq-text { flex: 1; }

/* Leaderboard list */
.leader-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.leader-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.leader-row:hover { background: rgba(255,255,255,0.07); }
.leader-rank {
  font-size: 1rem;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.leader-name {
  flex: 1;
  color: #CBD5E1;
  font-size: 0.85rem;
}
.leader-score {
  background: var(--primary-gradient);
  color: white;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}

/* Upcoming exam items */
.exam-item {
  padding: 12px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  border-left: 3px solid #818CF8;
  margin-bottom: 8px;
}
.exam-item-title {
  color: #E2E8F0;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.exam-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

/* Messages in login cards */
.login-page .card .error-message,
.login-page .card .answer-message {
  color: #FCA5A5;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.login-page .card .success-message {
  color: #6EE7B7;
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.login-page .card .explanation-message {
  background: rgba(79,70,229,0.1);
  border: 1px solid rgba(129,140,248,0.2);
  color: #C4B5FD;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-top: 12px;
}

/* Links card */
.login-page .card .links {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 16px;
  border-radius: var(--radius);
  margin-top: 16px;
}
.login-page .card .links h2 { font-size: 0.85rem; margin-bottom: 10px; }
.login-page .card .links a { color: #818CF8; font-size: 0.82rem; }
.login-page .card .links a:hover { color: #A5B4FC; }

.empty-state {
  color: rgba(255,255,255,0.35);
  font-size: 0.85rem;
  text-align: center;
  padding: 16px 0;
}

/* Login tab navigation — mobile */
.login-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
}
.login-tabs button {
  flex: 1;
  min-width: 0;
  background: transparent;
  color: rgba(255,255,255,0.5);
  border: none;
  padding: 10px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  min-height: 42px;
  font-family: inherit;
}
.login-tabs button.active {
  background: var(--primary-gradient);
  color: var(--white);
}
.login-section { display: none; }
.login-section.active { display: block; }

/* ========================================
   REGISTER PAGE — Dark centered
   ======================================== */
.register-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 40%, #1a1a3e 100%);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.register-wrapper h1 {
  color: #FFFFFF;
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 4px;
}
.register-wrapper .subtitle {
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 20px;
}
.register-card {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  width: 100%;
  max-width: 500px;
}
.register-card label { color: rgba(255,255,255,0.7); }
.register-card input[type="text"],
.register-card input[type="password"],
.register-card input[type="email"],
.register-card input[type="tel"] {
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.12);
  color: #E2E8F0;
}
.register-card input:focus {
  border-color: #818CF8;
  box-shadow: 0 0 0 3px rgba(129,140,248,0.2);
}
.register-card input::placeholder { color: rgba(255,255,255,0.3); }
.register-card button {
  background: var(--primary-gradient);
  width: 100%;
  height: 48px;
  font-weight: 700;
  font-size: 1rem;
}
.register-card .checkbox-label { color: rgba(255,255,255,0.6); }
.register-card a { color: #818CF8; }
.login-link { text-align: center; margin-top: 16px; }
.login-link a { color: #818CF8; font-weight: 500; font-size: 0.9rem; }

/* ========================================
   CHANGE PASSWORD — Centered
   ======================================== */
.change-pw-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.change-pw-wrapper .form-container {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  padding: 24px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.change-pw-wrapper h2 {
  text-align: center;
  margin-bottom: 20px;
}
.change-pw-wrapper .back-link { text-align: center; margin-top: 16px; }

/* ========================================
   ACCESSIBILITY
   ======================================== */
button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card, .form-container, .question-card, .result-question { animation: fadeIn 0.3s ease; }

/* ========================================
   DESKTOP ENHANCEMENTS (min-width: 768px)
   ======================================== */
@media (min-width: 768px) {
  :root { --navbar-h: 60px; }

  /* Navbar — horizontal links, no hamburger */
  .nav-toggle { display: none; }
  .nav-overlay { display: none !important; }
  .navbar { padding: 0 24px; }
  .navbar-brand { font-size: 1.2rem; }
  .navbar-links {
    position: static;
    width: auto;
    height: auto;
    background: transparent;
    flex-direction: row;
    padding: 0;
    box-shadow: none;
    gap: 2px;
  }
  .navbar-links a {
    padding: 8px 14px;
    font-size: 0.82rem;
    border-left: none;
    border-radius: var(--radius);
  }
  .navbar-links a:hover, .navbar-links a.active {
    background: rgba(79,70,229,0.25);
    border-left-color: transparent;
  }
  .navbar-profile {
    border-top: none;
    margin-top: 0;
    padding: 6px 14px;
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,0.08);
  }

  /* Page wrap gets breathing room */
  .page-wrap {
    padding: 20px 24px;
    max-width: 1600px;
    margin: 0 auto;
  }
  .page-wrap h1 { font-size: 1.4rem; }

  /* Cards get larger */
  .card { padding: 20px; }

  /* Form grid 2-col */
  .form-grid { grid-template-columns: 1fr 1fr; }

  /* Login page — split layout */
  .login-page {
    display: grid;
    grid-template-columns: 380px 1fr;
    padding: 0;
    gap: 0;
    max-width: none;
    margin: 0;
  }
  .login-tabs { display: none; }
  .login-section { display: block !important; }
  .login-left, .login-right {
    display: flex !important;
    flex-direction: column;
  }
  .login-left {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    padding: 32px 24px;
    justify-content: center;
    background: rgba(0,0,0,0.2);
    border-right: 1px solid rgba(255,255,255,0.06);
    overflow-y: auto;
  }
  .login-left .card { margin-bottom: 0; }
  .login-right {
    padding: 24px;
    gap: 16px;
    overflow-y: auto;
    max-height: 100vh;
  }
  .login-right .card { margin-bottom: 0; }
  .login-footer { display: block; }
  .login-logo { width: 60px; height: 60px; border-radius: 16px; }
  .login-logo span { font-size: 1.6rem; }
  .login-brand h1 { font-size: 1.7rem; }

  /* Register wider */
  .register-card { max-width: 560px; padding: 32px; }

  /* Exam topbar more space */
  .exam-topbar { padding: 12px 24px; }
  .exam-body { padding: 24px; }
  .question-card { padding: 28px; }

  /* Question nav drawer becomes a side panel on desktop */
  .q-drawer-toggle { display: none; }
  .q-drawer-overlay { display: none !important; }
  .q-drawer {
    position: static;
    transform: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 16px;
    max-height: none;
  }

  /* Exam layout — side panel on desktop */
  .exam-body {
    display: flex;
    gap: 20px;
    align-items: flex-start;
  }
  .exam-body .exam-main { flex: 1; min-width: 0; }
  .exam-body .exam-sidebar {
    width: 200px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
  }
}

/* ========================================
   LARGE DESKTOP (min-width: 1200px)
   ======================================== */
@media (min-width: 1200px) {
  /* Login — wider left, 2-col right grid */
  .login-page { grid-template-columns: 440px 1fr; }
  .login-left { padding: 40px 32px; }
  .login-right {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    padding: 32px 40px;
    gap: 20px;
    align-items: start;
    align-content: start;
  }
  #daily-tab { grid-column: 1 / -1; }
  .login-brand h1 { font-size: 1.8rem; }

  /* Tables wider */
  .page-wrap { max-width: 1800px; }

  .exam-body .exam-sidebar { width: 240px; }
}

/* ========================================
   PRINT (hide nav + controls)
   ======================================== */
@media print {
  .navbar, .nav-toggle, .exam-topbar, .exam-nav,
  .q-drawer-toggle, .q-drawer, .submit-exam-wrap,
  .profile-panel, .profile-panel-overlay { display: none !important; }
  .exam-body { padding: 0; }
}
