/* ============================================================
   CBT · Gaya tampilan
   ============================================================ */
:root {
  --brand: #2563eb;
  --brand-600: #1d4ed8;
  --brand-700: #1e40af;
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f7fb;
  --card: #ffffff;
  --side: #0b1736;
  --side-2: #13224a;
  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --bs-primary: #2563eb;
  --bs-primary-rgb: 37, 99, 235;
  --bs-link-color: #2563eb;
  --bs-link-color-rgb: 37, 99, 235;
  --bs-link-hover-color: #1d4ed8;
  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-border-color: #e2e8f0;
}

html, body { height: 100%; }
body {
  font-family: var(--bs-body-font-family);
  background: var(--bg);
  color: var(--ink);
  font-size: .925rem;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }
h1, h2, h3, h4, h5, h6 { color: inherit; }
.fw-semibold { font-weight: 600 !important; }
.text-muted { color: var(--muted) !important; }

.btn { border-radius: 10px; font-weight: 600; }
.btn-sm { border-radius: 8px; }
.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-bg: var(--brand-700); --bs-btn-active-border-color: var(--brand-700);
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-600);
}
.btn-soft { background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-100); }
.btn-soft:hover { background: var(--brand-100); color: var(--brand-700); }
.form-control, .form-select { border-radius: 10px; border-color: #d6dee9; padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: #93c5fd; box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15); }
.form-label { font-weight: 600; font-size: .85rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-text { font-size: .78rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: .9rem 1.1rem; font-weight: 700; }
.card-body { padding: 1.1rem; }
.badge-soft { font-weight: 600; letter-spacing: .01em; }

/* ---------- Layout admin ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 1040;
  background: linear-gradient(180deg, var(--side) 0%, #0e1d45 100%);
  color: #c7d2fe; display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07); color: #fff;
}
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 40px;
  background: linear-gradient(135deg, #3b82f6, #60a5fa); display: grid; place-items: center;
  color: #fff; font-size: 1.2rem; overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { font-weight: 800; font-size: .95rem; line-height: 1.15; }
.brand-sub { font-size: .72rem; color: #93a4d6; }
.side-nav { padding: .75rem .65rem 1.5rem; overflow-y: auto; flex: 1; }
.side-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #6f80b5; padding: 1rem .75rem .4rem; font-weight: 700; }
.side-link {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px;
  color: #c7d2fe; font-weight: 500; margin-bottom: 2px;
}
.side-link i { font-size: 1.05rem; opacity: .9; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, .35); }
.main { margin-left: 264px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1030; height: 62px; background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
}
.topbar .btn-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: .55rem; padding: .3rem .5rem; border-radius: 12px; color: var(--ink); }
.user-chip:hover { background: var(--bg); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700);
  display: grid; place-items: center; font-weight: 800; font-size: .85rem;
}
.content { padding: 1.5rem; flex: 1; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.page-title { color: var(--ink); font-size: 1.35rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.page-sub { margin: .2rem 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.footer-note { padding: 1rem 1.5rem; color: var(--muted); font-size: .78rem; }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1035; }
  .main { margin-left: 0; }
  .topbar .btn-toggle { display: inline-flex; }
  .content { padding: 1rem; }
}

/* ---------- Komponen ---------- */
.stat {
  display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); height: 100%;
}
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: 0 0 46px; }
.stat-val { font-size: 1.45rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .8rem; }
.bg-blue { background: #dbeafe; color: #1d4ed8; }
.bg-green { background: #dcfce7; color: #15803d; }
.bg-amber { background: #fef3c7; color: #b45309; }
.bg-violet { background: #ede9fe; color: #6d28d9; }
.bg-rose { background: #ffe4e6; color: #be123c; }
.bg-sky { background: #e0f2fe; color: #0369a1; }

.table { --bs-table-bg: transparent; margin-bottom: 0; vertical-align: middle; }
.table > thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; font-weight: 700;
}
.table > tbody td { border-color: #eef2f7; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f8fbff; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .6; }
.token-box {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: 1.6rem; font-weight: 800;
  letter-spacing: .25em; background: var(--brand-50); color: var(--brand-700);
  border: 2px dashed #93c5fd; border-radius: 12px; padding: .35rem .9rem; display: inline-block;
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.dot-off { background: #cbd5e1; }
.soal-text img, .q-text img { max-width: 100%; height: auto; border-radius: 8px; }
.thumb { max-height: 90px; max-width: 160px; border-radius: 8px; border: 1px solid var(--line); }
.opsi-row { display: flex; gap: .65rem; align-items: flex-start; padding: .6rem; border: 1px solid var(--line); border-radius: 12px; margin-bottom: .5rem; background: #fff; }
.opsi-letter { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-50); color: var(--brand-700); font-weight: 800; display: grid; place-items: center; flex: 0 0 32px; }
.opsi-pick { padding-top: .35rem; }
.opsi-pick .form-check-input { width: 1.25em; height: 1.25em; }
.ql-toolbar.ql-snow { border-radius: 10px 10px 0 0; border-color: #d6dee9; font-family: inherit; }
.ql-container.ql-snow { border-radius: 0 0 10px 10px; border-color: #d6dee9; font-family: inherit; font-size: .95rem; min-height: 160px; }
.ql-align-center { text-align: center; }
.ql-align-right { text-align: right; }
.ql-align-justify { text-align: justify; }
.nav-pills .nav-link { border-radius: 10px; font-weight: 600; color: var(--ink-2); }
.nav-pills .nav-link.active { background: var(--brand); }
.progress { border-radius: 99px; background: #eef2f7; }
.kbd-hint { font-size: .78rem; color: var(--muted); }

/* ---------- Halaman login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; }
.login-hero {
  position: relative; overflow: hidden; color: #fff; padding: 3rem;
  background: radial-gradient(1200px 600px at -10% 110%, rgba(56, 189, 248, .45), transparent 60%),
              linear-gradient(140deg, #0b1f57 0%, #1d4ed8 55%, #3b82f6 100%);
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero::after {
  content: ""; position: absolute; inset: 0; opacity: .12;
  background-image: radial-gradient(#fff 1px, transparent 1px); background-size: 22px 22px;
}
.login-hero > * { position: relative; z-index: 1; }
.hero-title { font-size: 2.3rem; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; max-width: 520px; }
.hero-text { color: #dbeafe; max-width: 460px; font-size: 1rem; }
.hero-feats { display: flex; flex-wrap: wrap; gap: .6rem; }
.hero-feats span { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); padding: .4rem .75rem; border-radius: 99px; font-size: .82rem; }
.login-side { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--bg); }
.login-card { width: 100%; max-width: 410px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 2rem; box-shadow: 0 20px 50px rgba(15, 23, 42, .08); }
.login-card .form-control { padding: .7rem .9rem; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.input-icon > .form-control { padding-left: 2.4rem; }
.toggle-pass { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: #94a3b8; }
@media (max-width: 991.98px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

/* ---------- Area siswa ---------- */
.siswa-nav { background: #fff; border-bottom: 1px solid var(--line); }
.siswa-nav .navbar-brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; color: var(--ink); font-size: .95rem; }
.hello-card {
  background: linear-gradient(135deg, #1e40af, #2563eb 60%, #38bdf8); color: #fff; border: 0;
  border-radius: 18px; padding: 1.4rem 1.5rem; position: relative; overflow: hidden;
}
.hello-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.exam-card { transition: transform .15s ease, box-shadow .15s ease; }
.exam-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15, 23, 42, .08); }
.meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; color: var(--muted); font-size: .82rem; }
.meta i { color: var(--brand); }
.score-ring {
  width: 150px; height: 150px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
  background: conic-gradient(var(--ring, #2563eb) calc(var(--p) * 1%), #e5edf7 0);
}
.score-ring > div { width: 118px; height: 118px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; }
.score-ring b { font-size: 2.1rem; line-height: 1; }

/* ---------- Halaman ujian ---------- */
body.exam { background: #eef3fa; user-select: none; -webkit-user-select: none; }
body.exam input, body.exam textarea { user-select: text; -webkit-user-select: text; }
.exam-top {
  position: sticky; top: 0; z-index: 1030; background: #fff; border-bottom: 1px solid var(--line);
  padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem;
}
.exam-title { font-weight: 800; font-size: .95rem; line-height: 1.2; min-width: 0; }
.exam-title small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer {
  margin-left: auto; display: flex; align-items: center; gap: .45rem; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 800; font-size: 1.15rem; background: var(--brand-50); color: var(--brand-700);
  padding: .35rem .8rem; border-radius: 10px; border: 1px solid var(--brand-100);
}
.timer.warn { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.timer.danger { background: #fee2e2; color: #b91c1c; border-color: #fecaca; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.save-state { font-size: .76rem; color: var(--muted); white-space: nowrap; }
.save-state.offline { color: var(--bad); font-weight: 700; }
.exam-wrap { max-width: 1240px; margin: 0 auto; padding: 1rem; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; }
.q-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: calc(100vh - 110px); }
.q-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); }
.q-num { background: var(--brand); color: #fff; font-weight: 800; border-radius: 10px; padding: .3rem .75rem; }
.q-body { padding: 1.25rem 1.25rem 1.5rem; font-size: var(--q-fs, 17px); line-height: 1.65; flex: 1; }
.q-text { margin-bottom: 1.1rem; color: var(--ink); }
.q-text p { margin-bottom: .5rem; }
.q-img { max-width: 100%; max-height: 380px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 1rem; }
.q-hint { font-size: .8em; color: var(--muted); margin-bottom: .6rem; }
.opt {
  display: flex; align-items: flex-start; gap: .8rem; padding: .75rem .9rem; border: 2px solid var(--line);
  border-radius: 14px; margin-bottom: .6rem; cursor: pointer; background: #fff; transition: border-color .12s, background .12s;
}
.opt:hover { border-color: #bfdbfe; background: #f8fbff; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .ltr {
  width: 2em; height: 2em; flex: 0 0 2em; border-radius: 50%; border: 2px solid #cbd5e1; display: grid; place-items: center;
  font-weight: 800; color: var(--ink-2); font-size: .9em;
}
.opt.square .ltr { border-radius: 8px; }
.opt .txt { padding-top: .15em; }
.opt .txt img { max-width: 100%; max-height: 220px; display: block; margin-top: .4rem; border-radius: 8px; }
.opt.selected { border-color: var(--brand); background: var(--brand-50); }
.opt.selected .ltr { background: var(--brand); border-color: var(--brand); color: #fff; }
.bs-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; max-width: 480px; }
.bs-wrap .opt { justify-content: center; font-weight: 700; }
.q-foot { display: flex; gap: .5rem; align-items: center; padding: .85rem 1.1rem; border-top: 1px solid var(--line); background: #fbfdff; border-radius: 0 0 16px 16px; }
.q-foot .btn { padding: .55rem 1rem; }
.btn-ragu { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }
.btn-ragu:hover, .btn-ragu.on { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.nav-panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 1rem; position: sticky; top: 76px; align-self: start; }
.nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
.nav-grid button {
  aspect-ratio: 1; border: 1.5px solid #d6dee9; background: #fff; border-radius: 10px; font-weight: 700; color: var(--ink-2);
  font-size: .85rem; position: relative;
}
.nav-grid button.answered { background: var(--brand); border-color: var(--brand); color: #fff; }
.nav-grid button.ragu { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.nav-grid button.current { outline: 3px solid #93c5fd; outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .74rem; color: var(--muted); margin-top: .8rem; }
.legend span::before { content: ""; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; border: 1.5px solid #d6dee9; }
.legend .l-ans::before { background: var(--brand); border-color: var(--brand); }
.legend .l-ragu::before { background: #f59e0b; border-color: #f59e0b; }
.overlay {
  position: fixed; inset: 0; z-index: 2000; background: rgba(11, 23, 54, .86); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.overlay.show { display: flex; }
.overlay-card { background: #fff; border-radius: 20px; max-width: 460px; width: 100%; padding: 2rem; text-align: center; }
.overlay-card .big-icon { font-size: 2.8rem; }
.btn-daftar { display: none; }
@media (max-width: 991.98px) {
  .exam-wrap { grid-template-columns: 1fr; padding: .6rem; }
  .nav-panel.desktop { display: none; }
  .btn-daftar { display: inline-flex; }
  .q-card { min-height: calc(100vh - 90px); }
  .q-body { padding: 1rem; }
  .exam-title small { max-width: 40vw; }
}
@media (max-width: 575.98px) {
  .q-foot .btn .lbl { display: none; }
  .save-state { display: none; }
}

/* ---------- Cetak ---------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}
