/* ═══════════════════════════════════════════════════
   MockTest Platform - Complete Design System
   Fully Responsive — Mobile, Tablet, Desktop
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Variables ───────────────────────────────────── */
:root {
  --primary: #5C6BC0;
  --primary-dark: #3949AB;
  --primary-light: #7986CB;
  --primary-glow: rgba(92, 107, 192, 0.25);
  --accent: #00BCD4;
  --accent-warm: #FF7043;
  --success: #26A69A;
  --warning: #FFA726;
  --danger: #EF5350;
  --gold: #FFD700;

  --bg: #0D0E1A;
  --bg-card: #13141F;
  --bg-elevated: #1A1B2E;
  --bg-hover: #1E2035;
  --border: rgba(255,255,255,0.07);
  --border-active: rgba(92,107,192,0.5);

  --text-primary: #E8EAFF;
  --text-secondary: #8892B0;
  --text-muted: #4A5568;

  --sidebar-width: 260px;
  --header-height: 64px;
  --bottom-nav-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-card: 0 2px 16px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 30px rgba(92,107,192,0.2);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Sora', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --bg: #F0F2FF;
  --bg-card: #FFFFFF;
  --bg-elevated: #E8EBF5;
  --bg-hover: #DDE0F0;
  --border: rgba(0,0,0,0.08);
  --border-active: rgba(92,107,192,0.4);
  --text-primary: #1A1B2E;
  --text-secondary: #4A5568;
  --text-muted: #8892B0;
  --shadow: 0 4px 24px rgba(92,107,192,0.12);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.08);
}

/* ─── Reset & Base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
  /* Prevent font size inflation on mobile */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport for mobile browsers */
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
  /* Prevent horizontal scroll on all devices */
  max-width: 100vw;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, textarea, select { font-family: var(--font); }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* ─── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

/* ─── Typography ──────────────────────────────────── */
h1 { font-size: clamp(1.5rem, 5vw, 2.8rem); font-weight: 800; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 3.5vw, 1.9rem); font-weight: 700; }
h3 { font-size: clamp(1rem, 2.5vw, 1.25rem); font-weight: 600; }
h4 { font-size: clamp(0.9rem, 2vw, 1.05rem); font-weight: 600; }
p  { color: var(--text-secondary); }
.mono { font-family: var(--font-mono); }

/* ─── Layout ──────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
  min-height: 100dvh;
  transition: margin-left 0.3s ease;
  width: 0; /* Prevents overflow beyond flex container */
  min-width: 0;
}

.page-content {
  padding: 28px 32px;
  max-width: 1280px;
  width: 100%;
}

/* ─── Sidebar ─────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.sidebar-logo-text { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.sidebar-logo-text span { color: var(--primary-light); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary-light);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: var(--transition);
}

.user-card:hover { background: var(--bg-hover); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid var(--border-active);
  overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-role { font-size: 0.7rem; color: var(--text-muted); }

/* ─── Header ──────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: var(--sidebar-width); right: 0;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 190;
  gap: 12px;
  transition: left 0.3s ease;
}

.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.header-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 9px 16px 9px 42px;
  border-radius: 99px;
  font-size: 0.88rem;
  transition: var(--transition);
  /* Prevent zoom on iOS */
  font-size: max(16px, 0.88rem);
}

.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.header-search input::placeholder { color: var(--text-muted); }

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}

.search-results-dropdown.show { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
}

.search-result-item:hover { background: var(--bg-hover); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
  font-size: 1rem;
  flex-shrink: 0;
  /* Minimum tap target */
  min-width: 38px;
  min-height: 38px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.mobile-menu-btn { display: none; }

/* ─── Notifications Panel ─────────────────────────── */
.notif-panel {
  position: fixed;
  top: 72px; right: 16px;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 150;
  display: none;
  max-height: 500px;
  overflow: hidden;
  flex-direction: column;
}

.notif-panel.show { display: flex; }

.notif-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.notif-list { overflow-y: auto; flex: 1; }

.notif-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.notif-item:hover { background: var(--bg-elevated); }
.notif-item.unread { background: rgba(92,107,192,0.06); }

.notif-dot-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
  flex-shrink: 0;
}

.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.notif-message { font-size: 0.78rem; color: var(--text-secondary); margin-top: 3px; }
.notif-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Bottom Nav (Mobile) ─────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 150;
  /* Safe area for notched phones */
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(12px);
}

.bottom-nav-inner {
  display: flex;
  height: var(--bottom-nav-height);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 8px 4px;
  transition: var(--transition);
  min-width: 44px; /* Minimum tap target */
  min-height: 44px;
}

.bottom-nav a.active, .bottom-nav a:hover { color: var(--primary-light); }
.bottom-nav a .bnav-icon { font-size: 1.2rem; line-height: 1; }

/* ─── Cards ───────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card:hover { border-color: var(--border-active); box-shadow: var(--shadow-glow); }
.card-sm { padding: 16px; }
.card-lg { padding: 32px; }

/* ─── Exam Cards ──────────────────────────────────── */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.exam-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition-slow);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
}

.exam-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-active);
  box-shadow: 0 12px 40px rgba(92,107,192,0.2);
}

.exam-card-banner {
  height: 120px;
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.exam-card-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.exam-card-icon {
  font-size: 2.5rem;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.exam-badge-premium {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(255, 215, 0, 0.9);
  color: #1a1100;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}

.exam-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.exam-card-category {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-light);
  margin-bottom: 6px;
}

.exam-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.exam-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.exam-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.exam-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.exam-price {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

.exam-price.free { color: var(--success); }

/* ─── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  /* Minimum touch target */
  min-height: 40px;
  cursor: pointer;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(92,107,192,0.4);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(92,107,192,0.6); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #0097A7);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,188,212,0.35);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #00796B);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #C62828);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover { border-color: var(--primary); color: var(--primary-light); background: var(--primary-glow); }

.btn-sm { padding: 6px 14px; font-size: 0.78rem; min-height: 34px; }
.btn-lg { padding: 14px 32px; font-size: 1rem; min-height: 52px; }
.btn-full { width: 100%; }

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

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

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: max(16px, 0.9rem); /* Prevent iOS zoom */
  transition: var(--transition);
  min-height: 44px; /* Touch target */
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238892B0' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

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

.form-error { color: var(--danger); font-size: 0.78rem; margin-top: 6px; }
.form-hint { color: var(--text-muted); font-size: 0.78rem; margin-top: 6px; }

/* ─── Stats / KPI Cards ───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--primary));
  border-radius: 3px 3px 0 0;
}

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

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--stat-color, var(--primary));
  opacity: 0.9;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  font-family: var(--font-mono);
}

.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.stat-change { font-size: 0.72rem; color: var(--success); font-weight: 600; margin-top: 4px; }

/* ─── Test Interface ──────────────────────────────── */
.test-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  align-items: start;
}

.test-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.test-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 8px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.test-timer.warning { color: var(--warning); border-color: var(--warning); }
.test-timer.danger { color: var(--danger); border-color: var(--danger); animation: pulse 1s infinite; }

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

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.question-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.question-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 24px;
}

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

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  width: 100%;
  min-height: 52px; /* Touch target */
}

.option-btn:hover { border-color: var(--primary-light); background: var(--primary-glow); }
.option-btn.selected { border-color: var(--primary); background: rgba(92,107,192,0.15); }
.option-btn.correct { border-color: var(--success); background: rgba(38,166,154,0.15); }
.option-btn.wrong { border-color: var(--danger); background: rgba(239,83,80,0.15); }

.option-key {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: var(--transition);
}

.option-btn.selected .option-key { background: var(--primary); border-color: var(--primary); color: #fff; }
.option-btn.correct .option-key { background: var(--success); border-color: var(--success); color: #fff; }
.option-btn.wrong .option-key { background: var(--danger); border-color: var(--danger); color: #fff; }

.option-text { font-size: 0.88rem; color: var(--text-primary); line-height: 1.5; padding-top: 3px; }

/* Question palette */
.question-palette {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 80px;
}

.palette-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.palette-legend-item { display: flex; align-items: center; gap: 6px; }

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  max-height: 360px;
  overflow-y: auto;
}

.palette-btn {
  aspect-ratio: 1;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: var(--transition);
  min-height: 36px; /* Touch target */
}

.palette-btn:hover { border-color: var(--primary); color: var(--primary-light); }
.palette-btn.answered { background: var(--primary); border-color: var(--primary); color: #fff; }
.palette-btn.bookmarked { background: var(--warning); border-color: var(--warning); color: #fff; }
.palette-btn.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* ─── Results Page ────────────────────────────────── */
.result-hero {
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 40px);
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}

.result-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 30%, rgba(255,255,255,0.15), transparent 60%);
  pointer-events: none;
}

.result-score-ring {
  width: clamp(120px, 20vw, 160px);
  height: clamp(120px, 20vw, 160px);
  border-radius: 50%;
  border: 6px solid rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  position: relative;
  z-index: 1;
}

.result-score-value {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1;
}

.result-score-label { font-size: 0.82rem; opacity: 0.8; }

/* ─── Leaderboard ─────────────────────────────────── */
.leaderboard-table { width: 100%; border-collapse: separate; border-spacing: 0 5px; }

.leaderboard-table th {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 16px;
  text-align: left;
}

.leaderboard-table td {
  padding: 12px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: var(--transition);
}

.leaderboard-table td:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.leaderboard-table td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.leaderboard-table tr:hover td { background: var(--bg-elevated); border-color: var(--border-active); }

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

.rank-1 { background: var(--gold); color: #1a1100; }
.rank-2 { background: #C0C0C0; color: #1a1a1a; }
.rank-3 { background: #CD7F32; color: #fff; }
.rank-other { background: var(--bg-elevated); color: var(--text-muted); }

/* ─── Charts ──────────────────────────────────────── */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: scale(0.92) translateY(20px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px 20px; display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* ─── Progress / Badges ───────────────────────────── */
.progress-bar { height: 6px; background: var(--bg-elevated); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-primary { background: var(--primary-glow); color: var(--primary-light); }
.badge-success { background: rgba(38,166,154,0.15); color: var(--success); }
.badge-warning { background: rgba(255,167,38,0.15); color: var(--warning); }
.badge-danger  { background: rgba(239,83,80,0.15); color: var(--danger); }
.badge-gold    { background: rgba(255,215,0,0.15); color: var(--gold); }

/* ─── Loading ─────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.spinner-sm { width: 18px; height: 18px; border-width: 2px; }

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

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

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

/* ─── Toast Notifications ─────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 260px;
  max-width: 360px;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-left: 4px solid var(--primary);
}

.toast.show { transform: translateX(0); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-message { font-size: 0.85rem; color: var(--text-primary); flex: 1; }

/* ─── Tabs ────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab-btn {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  white-space: nowrap;
  min-height: 38px;
}

.tab-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-card); }
.tab-btn:hover:not(.active) { color: var(--text-secondary); }

/* ─── Empty State ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 3.5rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; }

/* ─── Auth Pages ──────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
}

.auth-left {
  flex: 1;
  background: linear-gradient(135deg, var(--bg) 0%, var(--primary-dark) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(32px, 5vw, 60px);
  position: relative;
  overflow: hidden;
}

.auth-left::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(92,107,192,0.3), transparent 70%);
  top: -200px; left: -200px;
  pointer-events: none;
}

.auth-left::after {
  content: '';
  position: absolute;
  width: 350px; height: 350px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,188,212,0.2), transparent 70%);
  bottom: -100px; right: -100px;
  pointer-events: none;
}

.auth-right {
  width: 460px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: var(--bg-card);
  overflow-y: auto;
}

/* ─── PWA Install Banner ──────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 500;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
}

.install-banner.show { transform: translateY(0); }

/* ─── Section Headers ─────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title { font-size: 1.1rem; font-weight: 700; }

/* ─── Table ───────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover td { background: var(--bg-elevated); }

/* Table scroll wrapper for mobile */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }

/* ─── Utility Classes ─────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; } .mb-32 { margin-bottom: 32px; }
.mt-auto { margin-top: auto; }
.text-center { text-align: center; }
.text-sm { font-size: 0.82rem; } .text-xs { font-size: 0.72rem; }
.font-bold { font-weight: 700; }
.text-primary-color { color: var(--primary-light); }
.text-success { color: var(--success); } .text-danger { color: var(--danger); }
.text-warning { color: var(--warning); } .text-muted { color: var(--text-muted); }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius-sm); }
.rounded-full { border-radius: 99px; }

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

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

.animate-in { animation: fadeIn 0.35s ease forwards; }
.stagger-1 { animation-delay: 0.05s; opacity: 0; }
.stagger-2 { animation-delay: 0.1s; opacity: 0; }
.stagger-3 { animation-delay: 0.15s; opacity: 0; }
.stagger-4 { animation-delay: 0.2s; opacity: 0; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════ */

/* ─── Large Tablet / Small Desktop (max 1024px) ───── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .test-layout { grid-template-columns: 1fr 220px; }
  .page-content { padding: 24px; }
}

/* ─── Tablet (max 768px) ──────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 260px; /* Full width when open */
    --header-height: 56px;
  }

  /* Sidebar hidden by default on mobile */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 250;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.5);
  }

  .sidebar-overlay.show { display: block; }

  /* Header spans full width */
  .header { left: 0; padding: 0 16px; gap: 10px; }
  .header-search { flex: 1; max-width: none; }
  .header-search input { font-size: 16px; } /* Always 16px to prevent zoom */

  /* Main content full width */
  .main-content {
    margin-left: 0;
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  }

  .page-content { padding: 16px; }

  /* Bottom nav visible */
  .bottom-nav { display: flex; flex-direction: column; }

  /* Mobile menu button visible */
  .mobile-menu-btn { display: flex; }

  /* Notification panel full-ish width on mobile */
  .notif-panel {
    right: 8px;
    left: 8px;
    width: auto;
  }

  /* Grids */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .exam-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Test layout stacked */
  .test-layout { grid-template-columns: 1fr; }
  .question-palette { position: static; }

  /* Admin tabs scroll */
  .admin-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }

  /* Auth */
  .auth-left { display: none; }
  .auth-right { width: 100%; padding: 32px 24px; }

  /* Toast bottom above nav */
  .toast-container {
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
    left: 12px;
    right: 12px;
    max-width: none;
  }

  .toast { min-width: unset; max-width: 100%; width: 100%; }

  /* Modal */
  .modal { max-height: 85dvh; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}

/* ─── Small Mobile (max 480px) ───────────────────── */
@media (max-width: 480px) {
  .exam-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; font-size: 1.1rem; }
  .stat-value { font-size: 1.3rem; }

  .card { padding: 16px; }
  .question-card { padding: 16px; }

  .btn-lg { padding: 12px 24px; font-size: 0.95rem; }

  /* Leaderboard table scroll */
  .leaderboard-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .test-header { padding: 10px 14px; gap: 8px; }
  .test-timer { font-size: 1.1rem; padding: 6px 12px; }

  /* Result page */
  .result-hero { padding: 24px 16px; }

  /* Header — hide some elements on very small screens */
  .header-search { max-width: 180px; }
}

/* ─── Very Small (max 360px) ──────────────────────── */
@media (max-width: 360px) {
  .page-content { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr; }
  .header-search { display: none; } /* Hide header search, use search page instead */
  .exam-grid { gap: 10px; }
}

/* ─── Landscape Mobile ────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --header-height: 48px; }
  .bottom-nav { display: none; }
  .main-content { padding-bottom: 0; }
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .header { left: 0; }
  .mobile-menu-btn { display: flex; }
  .auth-page { align-items: flex-start; overflow-y: auto; }
  .auth-right { min-height: auto; padding: 24px; }
}

/* ─── Large screens (min 1400px) ──────────────────── */
@media (min-width: 1400px) {
  .page-content { padding: 36px 40px; }
  .exam-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ─── Print ───────────────────────────────────────── */
@media print {
  .sidebar, .header, .bottom-nav, .install-banner { display: none !important; }
  .main-content { margin-left: 0; padding-top: 0; }
  .page-content { padding: 0; max-width: none; }
}