/* ============================================================
   Assessment Engine — Stylesheet
   ============================================================ */

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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --primary: #4f8ef7;
  --primary-dark: #3a72d4;
  --success: #34c77b;
  --danger: #e05252;
  --warn: #f5a623;
  --text: #e8eaf0;
  --muted: #8891b0;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ---- Header ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner { width: 100%; max-width: 1200px; margin: auto; display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 1.2rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 0.4rem; }
.brand-icon { font-size: 1.5rem; }

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

/* ---- Footer ---- */
.site-footer { text-align: center; padding: 1.5rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); }

/* ---- Alerts ---- */
.alert {
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  font-size: 0.95rem;
}
.alert-error { background: #3b1a1a; border: 1px solid var(--danger); color: #fca5a5; }
.alert-success { background: #0f2a1e; border: 1px solid var(--success); color: #86efac; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--surface2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c43e3e; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.85rem; }
.btn-full { width: 100%; }
.mt-1 { margin-top: 1rem; }

/* ============================================================
   Upload Page
   ============================================================ */
.upload-page { display: flex; justify-content: center; padding: 2rem 0; }
.upload-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 560px; }
.upload-card h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.subtitle { color: var(--muted); margin-bottom: 2rem; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1.5rem;
}
.drop-zone.drag-over { border-color: var(--primary); background: #1a2744; }
.drop-icon { font-size: 3rem; margin-bottom: 0.8rem; }
.drop-text { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.25rem; }
.drop-sub { color: var(--muted); margin-bottom: 1rem; font-size: 0.9rem; }
.file-name { margin-top: 0.75rem; font-size: 0.9rem; color: var(--primary); }

.form-row { margin-bottom: 1.2rem; }
.form-row label { display: block; margin-bottom: 0.4rem; font-weight: 600; font-size: 0.9rem; }
.form-row input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

.format-hint { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.format-hint h3 { font-size: 0.95rem; color: var(--muted); margin-bottom: 0.75rem; }
.format-hint pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.82rem;
  color: #b0c4de;
  overflow-x: auto;
  margin-bottom: 0.6rem;
  white-space: pre-wrap;
}
.format-hint p { font-size: 0.85rem; color: var(--muted); }
.format-hint code { background: var(--surface2); padding: 0.1rem 0.35rem; border-radius: 4px; color: var(--primary); }

/* ============================================================
   Test Page
   ============================================================ */
.test-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Sidebar */
.question-grid-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  position: sticky;
  top: 72px;
}
.question-grid-panel h3 { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
.progress-summary { display: flex; flex-direction: column; gap: 2px; margin-bottom: 0.8rem; font-size: 0.82rem; }
.prog-answered { color: var(--success); font-weight: 600; }
.prog-remaining { color: var(--muted); }

.question-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 1rem; }
.grid-btn {
  width: 36px; height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.12s;
  font-weight: 600;
}
.grid-btn.answered { background: #0f2a1e; border-color: var(--success); color: var(--success); }
.grid-btn.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.grid-btn:hover:not(.current) { border-color: var(--primary); color: var(--text); }

.legend { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted); margin-bottom: 1rem; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }
.legend-dot.unanswered { background: var(--surface2); border: 1px solid var(--border); }
.legend-dot.answered { background: #0f2a1e; border: 1px solid var(--success); }
.legend-dot.current { background: var(--primary); }

/* Main question panel */
.question-panel { display: flex; flex-direction: column; gap: 1.2rem; }

.test-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.q-counter { font-weight: 600; color: var(--muted); }

.timer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  color: var(--text);
  transition: color 0.3s, border-color 0.3s;
}
.timer.timer-warn { color: var(--warn); border-color: var(--warn); }

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  min-height: 300px;
}
.q-number { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.multi-hint { font-size: 0.82rem; font-weight: 600; color: var(--primary); margin: -1rem 0 1rem; letter-spacing: 0.02em; }
.q-text {
  font-size: 1.1rem;
  line-height: 1.7;
  margin-bottom: 1.8rem;
  white-space: pre-wrap;
}

.options { display: flex; flex-direction: column; gap: 0.75rem; }
.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, background 0.12s;
  font-size: 0.97rem;
  line-height: 1.5;
}
.option-btn:hover { border-color: var(--primary); background: #1a2744; }
.option-btn.selected { border-color: var(--primary); background: #1a2744; color: #fff; }
.option-btn.selected .option-label { background: var(--primary); }
.option-label {
  min-width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: background 0.12s;
}
.option-text { flex: 1; }

.nav-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.nav-bar .btn { min-width: 130px; }

.loading, .error { color: var(--muted); padding: 1rem; text-align: center; font-style: italic; }
.error { color: var(--danger); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 440px;
  width: 90%;
}
.modal-box h2 { margin-bottom: 0.75rem; }
.modal-box p { color: var(--muted); margin-bottom: 1.5rem; line-height: 1.6; }
.modal-actions { display: flex; gap: 1rem; justify-content: flex-end; }

/* ============================================================
   Results Page
   ============================================================ */
.results-page { max-width: 900px; margin: 0 auto; }

.results-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  display: flex;
  align-items: center;
  gap: 2.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.score-circle {
  width: 130px; height: 130px;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 5px solid var(--border);
  flex-shrink: 0;
}
.score-circle.pass { border-color: var(--success); }
.score-circle.fail { border-color: var(--danger); }
.score-circle.neutral { border-color: var(--primary); }

.score-pct { font-size: 1.8rem; font-weight: 800; }
.score-label { font-size: 0.85rem; font-weight: 700; color: var(--muted); letter-spacing: 0.08em; }
.score-circle.pass .score-label { color: var(--success); }
.score-circle.fail .score-label { color: var(--danger); }

.score-detail p { color: var(--muted); margin-bottom: 0.4rem; }
.score-detail p:first-child { font-size: 1.15rem; font-weight: 600; color: var(--text); }
.hint { font-size: 0.85rem !important; font-style: italic; }

.result-actions { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }

.email-section { margin-top: 1.5rem; }
.email-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.email-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.email-input {
  flex: 1; min-width: 200px;
  padding: 0.5rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
}
.email-input:focus { outline: none; border-color: var(--primary); }
.email-status { font-size: 0.82rem; margin-top: 0.4rem; min-height: 1.2em; }
.email-ok { color: var(--success); }
.email-error { color: var(--danger); }

/* Review table */
.review-section h2 { margin-bottom: 1rem; }
.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.review-table th {
  background: var(--surface2);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.review-table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.review-table tr:last-child td { border-bottom: none; }
.review-table tr.row-correct { background: #0a1f16; }
.review-table tr.row-wrong { background: #1f0a0a; }
.q-text-cell { max-width: 320px; }
.skipped-text { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-pass { background: #0f2a1e; color: var(--success); }
.badge-fail { background: #2a0f0f; color: var(--danger); }
.badge-answered { background: #0f1e2a; color: var(--primary); }
.badge-skipped { background: var(--surface2); color: var(--muted); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .test-layout { grid-template-columns: 1fr; }
  .question-grid-panel { position: static; }
  .results-hero { flex-direction: column; align-items: flex-start; }
  .review-table { font-size: 0.82rem; }
  .q-text-cell { max-width: 180px; }
}
