/* =====================================================================
   CBT SMART SCHOOL – Design System
   Navy blue · putih · aksen biru elektrik · soft aurora · glass secukupnya
   ===================================================================== */
:root {
  --navy-950: #050d24;
  --navy-900: #0b1f4b;
  --navy-800: #12295f;
  --navy-700: #1a3a7c;
  --electric: #2f6bff;
  --electric-2: #00b4ff;
  --aurora-1: rgba(47, 107, 255, .18);
  --aurora-2: rgba(0, 180, 255, .14);
  --aurora-3: rgba(124, 92, 255, .12);
  --surface: #ffffff;
  --surface-2: #f4f7fd;
  --border: #e3e9f5;
  --text: #0f1b3d;
  --muted: #64748b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 61, .04), 0 8px 24px rgba(15, 27, 61, .06);
  --shadow-lg: 0 20px 50px rgba(11, 31, 75, .14);
  --sidebar-w: 264px;
  --glass: rgba(255, 255, 255, .72);
  --bs-primary: #2f6bff;
  --bs-primary-rgb: 47, 107, 255;
  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-link-color-rgb: 47, 107, 255;
}
[data-bs-theme="dark"] {
  --surface: #0f1a38;
  --surface-2: #0a1430;
  --border: #1f2d55;
  --text: #e6ecff;
  --muted: #93a3c7;
  --glass: rgba(15, 26, 56, .72);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --bs-body-bg: #070f26;
  --bs-body-color: #e6ecff;
  --bs-border-color: #1f2d55;
  --bs-secondary-bg: #0f1a38;
  --bs-tertiary-bg: #0c1631;
}

html, body { min-height: 100%; }
body {
  font-family: var(--bs-body-font-family);
  color: var(--text);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}
[data-bs-theme="dark"] body { background: #070f26; }

/* Aurora background */
.aurora-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora-bg::before, .aurora-bg::after, .aurora-bg span {
  content: ''; position: absolute; border-radius: 50%; filter: blur(80px); opacity: .9;
}
.aurora-bg::before { width: 620px; height: 620px; top: -220px; right: -120px; background: var(--aurora-1); animation: drift 22s ease-in-out infinite alternate; }
.aurora-bg::after { width: 520px; height: 520px; bottom: -200px; left: 10%; background: var(--aurora-2); animation: drift 28s ease-in-out infinite alternate-reverse; }
.aurora-bg span { width: 420px; height: 420px; top: 30%; left: 45%; background: var(--aurora-3); animation: drift 34s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(60px, 40px) scale(1.12); } }

/* ---------- Bootstrap overrides ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; letter-spacing: .1px; }
.btn-primary { background: linear-gradient(135deg, var(--electric), #4f86ff); border: 0; box-shadow: 0 6px 16px rgba(47, 107, 255, .28); }
.btn-primary:hover, .btn-primary:focus { background: linear-gradient(135deg, #2558db, var(--electric)); }
.btn-navy { background: var(--navy-900); color: #fff; border: 0; }
.btn-navy:hover { background: var(--navy-800); color: #fff; }
.btn-soft { background: rgba(47, 107, 255, .1); color: var(--electric); border: 0; }
.btn-soft:hover { background: rgba(47, 107, 255, .18); color: var(--electric); }
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--border); padding: .6rem .85rem; }
.form-control:focus, .form-select:focus { border-color: var(--electric); box-shadow: 0 0 0 .2rem rgba(47, 107, 255, .15); }
.form-label { font-weight: 600; font-size: .875rem; margin-bottom: .35rem; }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; font-weight: 700; }
.table { --bs-table-bg: transparent; vertical-align: middle; }
.table > :not(caption) > * > * { padding: .75rem .75rem; border-color: var(--border); }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.badge { font-weight: 600; border-radius: 999px; padding: .4em .75em; }
.badge-orange { background: #f97316; color: #fff; }
.badge-flag.badge-success { background: #16a34a; } .badge-flag.badge-warning { background: #eab308; color: #1f1300; } .badge-flag.badge-danger { background: #dc2626; }
.modal-content { border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.dropdown-menu { border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.nav-tabs .nav-link { font-weight: 600; }
.text-muted { color: var(--muted) !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; top: 0; bottom: 0; left: 0; z-index: 1040;
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
  color: #c9d6ff; display: flex; flex-direction: column; transition: transform .3s ease;
}
.sidebar::after { content: ''; position: absolute; top: 0; right: 0; width: 1px; height: 100%; background: linear-gradient(180deg, transparent, rgba(0, 180, 255, .35), transparent); }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; color: #fff; text-decoration: none; }
.brand-logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--electric), var(--electric-2)); box-shadow: 0 8px 20px rgba(0, 180, 255, .35); font-size: 1.25rem; color: #fff; overflow: hidden; }
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-text strong { display: block; font-size: .95rem; letter-spacing: .4px; }
.brand-text small { display: block; font-size: .7rem; color: #8fa6e6; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem .75rem 1rem; }
.sidebar-nav::-webkit-scrollbar { width: 4px; } .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px; color: #6f86c9; padding: 1rem .75rem .4rem; font-weight: 700; }
.sidebar-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 10px; color: #c9d6ff; text-decoration: none; font-size: .9rem; font-weight: 500; transition: all .2s; position: relative; }
.sidebar-link i { font-size: 1.1rem; width: 22px; text-align: center; opacity: .85; }
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-link.active { background: linear-gradient(90deg, rgba(47, 107, 255, .35), rgba(47, 107, 255, .08)); color: #fff; }
.sidebar-link.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--electric-2); box-shadow: 0 0 12px var(--electric-2); }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .06); font-size: .75rem; color: #6f86c9; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.5rem; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-weight: 700; font-size: 1.05rem; margin: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--surface); color: var(--text); position: relative; }
.icon-btn:hover { border-color: var(--electric); color: var(--electric); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: #fff; font-size: .62rem; display: grid; place-items: center; font-weight: 700; }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy-700), var(--electric)); color: #fff; font-weight: 700; font-size: .9rem; }
.content { padding: 1.5rem; flex: 1; animation: fadeUp .35s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.footer { padding: 1rem 1.5rem; font-size: .78rem; color: var(--muted); }

.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(5, 13, 36, .5); z-index: 1035; }
  .main { margin-left: 0; }
  .content { padding: 1rem; }
  .topbar { padding: .65rem 1rem; }
}

/* ---------- Components ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }
.stat-card { position: relative; overflow: hidden; padding: 1.15rem 1.25rem; height: 100%; }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; color: #fff; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1.1; margin-top: .75rem; }
.stat-card .stat-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat-card::after { content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; right: -40px; top: -40px; background: var(--tint, rgba(47, 107, 255, .08)); }
.g-blue { background: linear-gradient(135deg, #2f6bff, #00b4ff); --tint: rgba(47,107,255,.08); }
.g-navy { background: linear-gradient(135deg, #0b1f4b, #1a3a7c); }
.g-green { background: linear-gradient(135deg, #10b981, #34d399); }
.g-orange { background: linear-gradient(135deg, #f97316, #fbbf24); }
.g-purple { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.g-red { background: linear-gradient(135deg, #ef4444, #f87171); }
.glass { background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.75rem; display: block; margin-bottom: .75rem; color: var(--electric); opacity: .6; }
.pulse-dot { position: relative; padding-left: 1.4em !important; }
.pulse-dot::before { content: ''; position: absolute; left: .55em; top: 50%; width: .45em; height: .45em; margin-top: -.225em; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.8); } 70% { box-shadow: 0 0 0 6px rgba(255,255,255,0); } 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); } }
.list-clean { list-style: none; padding: 0; margin: 0; }
.mini-progress { height: 8px; border-radius: 8px; background: var(--border); overflow: hidden; }
.mini-progress > div { height: 100%; background: linear-gradient(90deg, var(--electric), var(--electric-2)); border-radius: 8px; transition: width .4s; }
.q-text { white-space: normal; word-wrap: break-word; }
.q-img { max-width: 100%; max-height: 320px; border-radius: 12px; border: 1px solid var(--border); }
.opt-row { display: flex; gap: .5rem; align-items: flex-start; }
.token-box { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 1.6rem; letter-spacing: 6px; font-weight: 800; color: var(--electric); }
.notif-item { display: block; padding: .7rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: .85rem; }
.notif-item.unread { background: rgba(47, 107, 255, .06); }
.notif-item:hover { background: rgba(47, 107, 255, .1); }
.dt-container .dt-search input, .dt-container .dt-length select { border-radius: 10px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 10% 10%, rgba(0,180,255,.35), transparent 60%), radial-gradient(900px 500px at 90% 90%, rgba(124,92,255,.35), transparent 60%), linear-gradient(135deg, var(--navy-950), var(--navy-800)); }
.auth-hero h1 { font-weight: 800; font-size: 2.4rem; line-height: 1.15; }
.auth-hero .feature { display: flex; gap: .8rem; align-items: center; margin-bottom: .9rem; color: #c9d6ff; }
.auth-hero .feature i { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.08); color: var(--electric-2); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 420px; }
.grid-lines { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 40px 40px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------- Student UI (ramah anak SD) ---------- */
.student-top { background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); color: #fff; }
.student-top a { color: #fff; }
.student-nav .nav-link { color: #c9d6ff; font-weight: 600; border-radius: 10px; padding: .5rem .9rem; }
.student-nav .nav-link.active, .student-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.12); }
.exam-card { transition: transform .2s, box-shadow .2s; }
.exam-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.big-btn { padding: .9rem 1.4rem; font-size: 1.05rem; border-radius: 14px; }

/* ---------- Exam workspace ---------- */
.exam-body { background: var(--surface-2); user-select: none; -webkit-user-select: none; }
.exam-body textarea, .exam-body input { user-select: text; -webkit-user-select: text; }
.exam-header { position: sticky; top: 0; z-index: 1020; background: var(--navy-900); color: #fff; padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; }
.timer { font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 800; font-size: 1.25rem; padding: .35rem .9rem; border-radius: 10px; background: rgba(255,255,255,.1); }
.timer.warn { background: #f59e0b; color: #1f1300; } .timer.danger { background: #ef4444; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .65; } }
.exam-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1rem; padding: 1rem; max-width: 1280px; margin: 0 auto; }
@media (max-width: 991.98px) { .exam-layout { grid-template-columns: 1fr; } .exam-side { order: -1; } }
.question-card { padding: 1.5rem; font-size: 1.12rem; line-height: 1.7; }
.question-no { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; color: var(--electric); }
.option-item { display: flex; gap: .9rem; align-items: flex-start; padding: .9rem 1rem; border: 2px solid var(--border); border-radius: 14px; cursor: pointer; margin-bottom: .7rem; transition: all .15s; background: var(--surface); }
.option-item:hover { border-color: #9db8ff; }
.option-item.selected { border-color: var(--electric); background: rgba(47, 107, 255, .08); }
.option-letter { width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-weight: 800; border: 2px solid var(--border); background: var(--surface-2); }
.option-item.selected .option-letter { background: var(--electric); color: #fff; border-color: var(--electric); }
.option-img { max-width: 220px; max-height: 160px; border-radius: 8px; display: block; margin-top: .4rem; }
.nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .45rem; }
.nav-num { aspect-ratio: 1; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); font-weight: 700; display: grid; place-items: center; cursor: pointer; font-size: .9rem; position: relative; color: var(--text); }
.nav-num.answered { background: #10b981; border-color: #10b981; color: #fff; }
.nav-num.marked { background: #f59e0b; border-color: #f59e0b; color: #1f1300; }
.nav-num.current { outline: 3px solid var(--electric); outline-offset: 1px; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; margin-right: .7rem; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 2px solid var(--border); }
.save-status { font-size: .8rem; }
.exam-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(5, 13, 36, .92); color: #fff; display: none; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.exam-overlay.show { display: flex; }
.exam-overlay .box { max-width: 480px; }
.exam-overlay i { font-size: 3.5rem; }
.answer-area { min-height: 220px; font-size: 1.05rem; line-height: 1.6; }
.math-preview { border: 1px dashed var(--border); border-radius: 10px; padding: .6rem .8rem; min-height: 2.5rem; background: var(--surface-2); font-size: .95rem; }

/* ---------- Monitoring ---------- */
.conn-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: .35rem; }
.conn-online { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.conn-offline { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
.conn-idle { background: #94a3b8; }
.row-flag-perlu_pemeriksaan { background: rgba(239, 68, 68, .07) !important; }
.row-flag-mencurigakan { background: rgba(249, 115, 22, .06) !important; }
.live-feed { max-height: 420px; overflow-y: auto; }
.live-feed li { padding: .55rem .25rem; border-bottom: 1px solid var(--border); font-size: .84rem; animation: fadeUp .3s; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .no-print, .footer { display: none !important; }
  .main { margin: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none !important; border: 0 !important; }
  .aurora-bg { display: none; }
}
