/* ============================================================
   ExamPortal — Global Stylesheet
   ============================================================ */

:root {
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --success:      #16a34a;
  --danger:       #dc2626;
  --warning:      #d97706;
  --muted:        #6b7280;
  --border:       #e5e7eb;
  --bg:           #f9fafb;
  --white:        #ffffff;
  --radius:       8px;
  --shadow:       0 1px 4px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.12);
  --font:         'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: #1f2937;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Container ─────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 54px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.nav-brand { font-size: 18px; font-weight: 700; color: var(--primary); flex: 1; }
.nav-brand .logo-icon { font-size: 20px; margin-right: 6px; }
.nav-center { flex: 1; display: flex; justify-content: center; }
.nav-right  { display: flex; align-items: center; gap: 8px; }
.nav-user   { font-size: 13px; color: var(--muted); }
.btn-ghost  { background: none; color: #374151; padding: 5px 10px; }
.btn-ghost:hover { background: var(--bg); border-radius: var(--radius); text-decoration: none; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 20px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; transition: all .15s; text-decoration: none; gap: 6px;
}
.btn:hover { text-decoration: none; filter: brightness(.93); }
.btn-primary    { background: var(--primary);  color: #fff; }
.btn-danger     { background: var(--danger);   color: #fff; }
.btn-outline    { background: transparent; border: 1.5px solid var(--border); color: #374151; }
.btn-outline:hover { border-color: #9ca3af; }
.btn-outline-danger { background: transparent; border: 1.5px solid var(--danger); color: var(--danger); }
.btn-sm  { padding: 5px 13px; font-size: 13px; }
.btn-block { width: 100%; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: #374151; margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font); color: #1f2937;
  background: var(--white); transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; cursor: pointer; }
.checkbox-label input { width: auto; }
.admin-form { background: var(--white); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: 14px; font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Auth page ──────────────────────────────────────────── */
.auth-page { background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card {
  background: var(--white); border-radius: 14px; padding: 40px 36px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-md);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 40px; }
.auth-logo h1 { font-size: 24px; color: var(--primary); margin-top: 6px; }
.auth-logo p  { color: var(--muted); font-size: 14px; }
.auth-footer  { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* ── Page title ─────────────────────────────────────────── */
.page-title { font-size: 22px; font-weight: 700; color: #111827; margin-bottom: 16px; }

/* ── Exam grid (dashboard) ──────────────────────────────── */
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px,1fr)); gap: 20px; }
.exam-card {
  background: var(--white); border-radius: 12px; padding: 22px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s;
}
.exam-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.exam-card.taken { opacity: .75; }
.exam-card h3 { font-size: 17px; color: #111827; margin-bottom: 6px; }
.exam-desc { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.exam-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.exam-meta span { background: var(--bg); padding: 3px 9px; border-radius: 20px; }

/* ── Stats ──────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--white); border-radius: 12px; padding: 22px 20px;
  box-shadow: var(--shadow); text-align: center; border: 1px solid var(--border);
}
.stat-icon { font-size: 32px; margin-bottom: 6px; }
.stat-val  { font-size: 30px; font-weight: 700; color: var(--primary); }
.stat-lbl  { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── Quick links ────────────────────────────────────────── */
.admin-quick-links { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.quick-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; background: var(--white);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-weight: 500; font-size: 14px; color: #374151;
  transition: all .15s;
}
.quick-link:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; background: #eff6ff; }

/* ── Tables ─────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th { background: #f3f4f6; padding: 11px 14px; text-align: left; font-size: 13px; font-weight: 600; color: #374151; border-bottom: 1px solid var(--border); }
.data-table td { padding: 11px 14px; border-bottom: 1px solid #f3f4f6; font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.action-btns { display: flex; flex-wrap: wrap; gap: 6px; }

.text-success { color: var(--success); font-weight: 600; }
.text-danger  { color: var(--danger);  font-weight: 600; }
.muted        { color: var(--muted); }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-muted   { background: #f3f4f6; color: #6b7280; }

/* ── Instructions page ──────────────────────────────────── */
.instructions-card {
  background: var(--white); border-radius: 12px; padding: 36px;
  box-shadow: var(--shadow); margin-top: 20px;
}
.instructions-card h2 { font-size: 22px; margin-bottom: 6px; }
.instructions-card h3 { font-size: 18px; margin: 10px 0 16px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; margin: 20px 0; }
.info-item {
  background: var(--bg); border-radius: 8px; padding: 14px 16px;
  border: 1px solid var(--border); text-align: center;
}
.info-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.info-val   { font-size: 18px; font-weight: 700; color: #111827; }
.section-breakdown { margin: 20px 0; }
.section-breakdown h4 { margin-bottom: 10px; font-size: 15px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.instructions-list ul { padding-left: 20px; }
.instructions-list li { margin-bottom: 6px; font-size: 14px; color: #374151; }

/* ── Exam interface ─────────────────────────────────────── */
.timer-box {
  background: #fff3cd; border: 1.5px solid #ffc107; border-radius: 8px;
  padding: 5px 18px; font-size: 15px; font-weight: 700; color: #856404;
}
.timer-box.danger { background: #fee2e2; border-color: var(--danger); color: var(--danger); animation: pulse .8s infinite; }
@keyframes pulse { 0%,100%{ opacity:1; } 50%{ opacity:.5; } }

.section-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.section-tab {
  padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 500;
  background: var(--bg); border: 1.5px solid var(--border);
  cursor: pointer; color: #374151; transition: all .15s;
}
.section-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.question-panel {
  background: var(--white); border-radius: 12px; padding: 28px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.question-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.q-number { font-size: 18px; font-weight: 700; color: var(--primary); }
.q-section-badge { background: #eff6ff; color: var(--primary); border-radius: 20px; padding: 3px 12px; font-size: 12px; font-weight: 600; }
.q-marks-badge   { background: #f0fdf4; color: var(--success); border-radius: 20px; padding: 3px 12px; font-size: 12px; font-weight: 600; margin-left: auto; }

.question-text { font-size: 16px; line-height: 1.7; color: #1f2937; margin-bottom: 22px; }

.options-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.option-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: 8px;
  border: 2px solid var(--border); cursor: pointer;
  transition: all .15s; background: var(--white);
}
.option-item:hover { border-color: var(--primary); background: #eff6ff; }
.option-item.selected { border-color: var(--primary); background: #dbeafe; }
.option-key { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); display:flex; align-items:center; justify-content:center; font-weight: 700; font-size: 13px; flex-shrink:0; }
.option-item.selected .option-key { background: var(--primary); border-color: var(--primary); color: #fff; }
.option-text { font-size: 15px; }

.question-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.nav-buttons { display: flex; justify-content: space-between; align-items: center; }

/* ── Question palette ───────────────────────────────────── */
.palette-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.q-status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 12px; }
.q-attempted   { background: #dcfce7; color: #166534; }
.q-notanswered { background: #fee2e2; color: #991b1b; }
.q-notvisited  { background: #f3f4f6; color: #6b7280; }
.q-review      { background: #fef9c3; color: #854d0e; }

.palette-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 6px; margin-bottom: 16px; }
.palette-btn {
  width: 36px; height: 36px; border-radius: 6px; border: none;
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s; background: #f3f4f6; color: #6b7280;
}
.palette-btn:hover { transform: scale(1.1); }
.palette-btn.st-attempted   { background: #16a34a; color: #fff; }
.palette-btn.st-notanswered { background: #dc2626; color: #fff; }
.palette-btn.st-review      { background: #d97706; color: #fff; }
.palette-btn.st-current     { box-shadow: 0 0 0 3px var(--primary); }

.summary-box { background: var(--bg); border-radius: 8px; padding: 12px; font-size: 13px; }
.summary-box div { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: var(--success); }
.dot-red    { background: var(--danger); }
.dot-yellow { background: var(--warning); }
.dot-gray   { background: #9ca3af; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 999; display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--white); border-radius: 14px; padding: 32px;
  max-width: 420px; width: 90%; box-shadow: var(--shadow-md); text-align: center;
}
.modal-box h3 { font-size: 20px; margin-bottom: 14px; }

/* ── Result page ────────────────────────────────────────── */
.result-card { background: var(--white); border-radius: 12px; padding: 36px; box-shadow: var(--shadow); margin-top: 20px; }
.result-hero { text-align: center; margin-bottom: 30px; }
.result-hero h2 { font-size: 26px; }
.result-hero h3 { color: var(--muted); font-size: 16px; font-weight: 400; margin: 4px 0 20px; }
.score-circle { display: inline-block; margin: 0 auto 8px; }
.score-num   { font-size: 56px; font-weight: 800; color: var(--primary); line-height: 1; }
.score-total { font-size: 20px; color: var(--muted); }
.score-pct   { font-size: 18px; font-weight: 600; color: var(--success); }

.result-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 16px; margin-bottom: 30px; }
.stat-box { border-radius: 12px; padding: 22px; text-align: center; }
.stat-box.correct     { background: #dcfce7; }
.stat-box.incorrect   { background: #fee2e2; }
.stat-box.unattempted { background: #f3f4f6; }
.stat-box.accuracy    { background: #dbeafe; }
.stat-box .stat-num   { font-size: 32px; font-weight: 700; }
.stat-box.correct .stat-num   { color: var(--success); }
.stat-box.incorrect .stat-num { color: var(--danger); }
.stat-box.accuracy .stat-num  { color: var(--primary); }
.stat-box .stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.section-header-bar { background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 6px; font-weight: 600; font-size: 14px; margin: 16px 0 8px; }

.answer-row { border-radius: 8px; padding: 14px 16px; margin-bottom: 8px; }
.answer-correct     { background: #f0fdf4; border-left: 4px solid var(--success); }
.answer-incorrect   { background: #fff5f5; border-left: 4px solid var(--danger); }
.answer-unattempted { background: #f9fafb; border-left: 4px solid #d1d5db; }
.ans-q { font-size: 14px; margin-bottom: 8px; }
.ans-opts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.opt-chip { padding: 4px 12px; border-radius: 20px; font-size: 13px; background: var(--bg); border: 1px solid var(--border); }
.opt-correct { background: #dcfce7; border-color: #86efac; font-weight: 700; }
.opt-wrong   { background: #fee2e2; border-color: #fca5a5; font-weight: 700; text-decoration: line-through; }
.ans-result  { margin-top: 4px; }

/* ── Empty state ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 15px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .container { padding: 16px 12px; }
  .auth-card  { padding: 28px 20px; }
  .form-row   { grid-template-columns: 1fr; }
  .result-stats { grid-template-columns: repeat(2,1fr); }
  .navbar { padding: 0 12px; }
  .nav-brand { font-size: 15px; }
  .question-panel { padding: 18px; }
}
