/* Ujian Online CAT — gaya dasar, mobile-first, font cukup besar untuk aksesibilitas (skill seo) */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f4f6f8;
  color: #222;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 4px 18px rgba(0,0,0,.08);
}

h1 { font-size: 22px; margin-bottom: 4px; color: #14532d; }
.sub { color: #555; margin-bottom: 20px; font-size: 14px; }

label { display: block; font-weight: 600; margin: 14px 0 4px; font-size: 14px; }

input {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 8px;
}

button {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  font-size: 16px;
  font-weight: 600;
  background: #15803d;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
button:hover { background: #166534; }
button:disabled { background: #94a3b8; cursor: not-allowed; }

#pesan { margin-top: 12px; font-size: 14px; min-height: 18px; }
#pesan.error { color: #b91c1c; }
#pesan.ok { color: #15803d; }

@media (max-width: 420px) { .card { padding: 18px; } }

/* ============================================================
   SISTEM TAMPILAN (view) — hanya satu view terlihat
   ============================================================ */
.view[hidden] { display: none !important; }

.view-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  width: 100%;
}

.card-wide { max-width: 560px; }

/* ---- daftar fakta (jumlah soal, durasi, nilai) ---- */
.facts {
  list-style: none;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin: 18px 0;
}
.facts li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  font-size: 14px;
  border-top: 1px solid #e2e8f0;
}
.facts li:first-child { border-top: none; }
.facts li span { color: #555; }
.facts li b { text-align: right; color: #14532d; }
.facts-total { background: #f0fdf4; font-size: 16px !important; }
.facts-total b { font-size: 20px; }

/* ---- kotak peringatan / instruksi ---- */
.notice {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  color: #78350f;
  margin: 0 0 4px;
}
.notice b { display: block; margin-bottom: 6px; color: #92400e; }
.notice ol { margin: 0; padding-left: 20px; }
.notice li { margin: 6px 0; }

.kecil { font-size: 13px; color: #64748b; margin-top: 14px; text-align: center; }

/* ---- tombol varian ---- */
.btn-primary {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  font-size: 16px;
  font-weight: 600;
  background: #15803d;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary:hover { background: #166534; }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-sm { width: auto; margin-top: 0; padding: 10px 18px; font-size: 14px; }

.btn-ghost {
  background: #fff;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover { background: #f1f5f9; }
.btn-ghost.aktif { background: #fef3c7; border-color: #f59e0b; color: #92400e; }

.btn-kumpul {
  background: #b91c1c;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-kumpul:hover { background: #991b1b; }
.btn-kumpul:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: 14px; padding: 12px; }

/* ============================================================
   VIEW UJIAN
   ============================================================ */
.view-exam { display: block; width: 100%; align-self: flex-start; min-height: 100vh; }

body:has(#view-ujian:not([hidden])) {
  display: block;
  padding: 0;
  align-items: stretch;
}

/* ---- bilah atas ---- */
.exam-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #14532d;
  color: #fff;
  flex-wrap: wrap;
}
.exam-bar-left { font-size: 14px; display: flex; gap: 6px; align-items: center; }
.exam-bar-left .who { font-weight: 700; }
.exam-bar-left .dot { opacity: .6; }
.exam-bar-right { display: flex; align-items: center; gap: 12px; }

.timer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.timer-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.timer-val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.warning .timer-val { color: #fcd34d; }
.timer.danger  .timer-val { color: #fca5a5; animation: kedip 1s infinite; }
@keyframes kedip { 50% { opacity: .35; } }

/* ---- penanda simpan ---- */
.save-flag {
  height: 22px;
  font-size: 12px;
  padding: 2px 16px;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  transition: color .2s;
}
.save-flag.ok    { color: #15803d; }
.save-flag.error { color: #b91c1c; background: #fee2e2; }

/* ---- tata letak dua kolom ---- */
.exam-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  align-items: start;
}

/* ---- panel soal ---- */
.soal-panel { background: #fff; border-radius: 12px; padding: 22px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }

.soal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}
.soal-meta b { color: #14532d; font-size: 15px; }
.soal-tingkat {
  background: #e0f2fe;
  color: #075985;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.soal-tingkat:empty { display: none; }

.soal-teks {
  font-size: 17px;
  line-height: 1.65;
  margin-bottom: 20px;
  white-space: pre-wrap;
  color: #0f172a;
}

.opsi-list { display: flex; flex-direction: column; gap: 10px; }

.opsi {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: inherit;
  color: #0f172a;
}
.opsi:hover { border-color: #86efac; background: #f0fdf4; }
.opsi.dipilih { border-color: #15803d; background: #f0fdf4; }
.opsi:focus-visible { outline: 3px solid #86efac; outline-offset: 2px; }

.opsi-huruf {
  flex: 0 0 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e2e8f0;
  font-weight: 700;
  font-size: 13px;
  color: #475569;
}
.opsi.dipilih .opsi-huruf { background: #15803d; color: #fff; }
.opsi-teks { flex: 1; }

/* ---- aksi bawah soal ---- */
.soal-aksi {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
}
.nav-pair { display: flex; gap: 8px; }

/* ---- panel navigasi ---- */
.nav-panel {
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  position: sticky;
  top: 68px;
}
.nav-panel h2 { font-size: 14px; margin-bottom: 10px; color: #14532d; }

.legend { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: #64748b; margin-bottom: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid #cbd5e1; }
.lg-isi   { background: #15803d; border-color: #15803d; }
.lg-ragu  { background: #f59e0b; border-color: #f59e0b; }
.lg-kosong{ background: #fff; }

.nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.nav-btn {
  aspect-ratio: 1;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.nav-btn:hover { border-color: #15803d; }
.nav-btn.isi    { background: #15803d; border-color: #15803d; color: #fff; }
.nav-btn.ragu   { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.nav-btn.aktif  { outline: 3px solid #14532d; outline-offset: 1px; }

.nav-count { font-size: 12px; color: #64748b; text-align: center; }
.nav-count b { color: #14532d; }

/* ============================================================
   SELESAI
   ============================================================ */
.selesai-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
}
.selesai-icon.gagal { background: #fee2e2; color: #b91c1c; }
#view-selesai .card { text-align: center; }
#view-selesai h1 { text-align: center; }
#view-selesai .facts li { text-align: left; }

/* ============================================================
   OVERLAY & DIALOG
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}
.overlay[hidden] { display: none !important; }

.dialog {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  text-align: center;
}
.dialog h2 { font-size: 19px; color: #14532d; margin-bottom: 8px; }
.dialog p { font-size: 14px; color: #475569; }
.dialog-aksi { display: flex; gap: 10px; margin-top: 20px; }
.dialog-aksi button { flex: 1; margin-top: 0; }

.dialog-warning { border-top: 6px solid #f59e0b; }
.dialog-warning h2 { color: #92400e; }
.warn-icon {
  width: 48px; height: 48px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #fef3c7;
  color: #b45309;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
}
.warn-count { margin-top: 12px; font-weight: 600; color: #92400e !important; }
.warn-count b { font-size: 17px; }

/* ---- loading ---- */
.loading { text-align: center; color: #fff; }
.spinner {
  width: 40px; height: 40px;
  margin: 0 auto 12px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: putar .8s linear infinite;
}
@keyframes putar { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIF — tablet & ponsel
   ============================================================ */
@media (max-width: 860px) {
  .exam-body { grid-template-columns: 1fr; gap: 14px; padding: 14px 12px 30px; }
  .nav-panel { position: static; order: -1; }
  .nav-grid { grid-template-columns: repeat(10, 1fr); gap: 7px; }
  .nav-panel h2, .legend { display: none; }
}

@media (max-width: 480px) {
  .exam-bar { padding: 8px 12px; }
  .timer-val { font-size: 17px; }
  .soal-panel { padding: 16px; }
  .soal-teks { font-size: 16px; }
  .opsi { font-size: 14px; padding: 11px 12px; }
  /* 6 kolom: tombol ~48px, cukup besar untuk jari (WCAG 2.5.5 target 44px) */
  .nav-grid { grid-template-columns: repeat(6, 1fr); gap: 8px; }
  .nav-btn { font-size: 14px; min-height: 44px; }
  .soal-aksi { flex-direction: column-reverse; align-items: stretch; }
  .nav-pair { display: grid; grid-template-columns: 1fr 1fr; }
  .btn-sm { width: 100%; min-height: 44px; }
  .btn-ghost, .btn-primary, .btn-kumpul { min-height: 44px; }
}

/* layar sangat kecil (HP lama 320px): 5 kolom agar tetap >= 44px */
@media (max-width: 360px) {
  .nav-grid { grid-template-columns: repeat(5, 1fr); }
  .soal-panel { padding: 12px; }
  .exam-bar { flex-wrap: wrap; gap: 8px; }
}

/* cetak: sembunyikan navigasi & timer */
@media print {
  .exam-bar, .nav-panel, .soal-aksi, .save-flag, .overlay { display: none !important; }
  .exam-body { display: block; }
}
