/* ============ Ujian Online - stylesheet ============ */
:root {
    --primary: #4338ca;
    --primary-dark: #3730a3;
    --primary-soft: #eef2ff;
    --sidebar: #1e1b4b;
    --sidebar-hover: #312e81;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --green: #059669;
    --green-soft: #d1fae5;
    --red: #dc2626;
    --red-soft: #fee2e2;
    --amber: #d97706;
    --amber-soft: #fef3c7;
    --blue: #2563eb;
    --blue-soft: #dbeafe;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px -12px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
}

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

/* ---------------- Layout ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--sidebar);
    color: #c7d2fe;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex; gap: 10px; align-items: center;
    padding: 18px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    color: #fff;
}
.brand-logo { font-size: 26px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: #a5b4fc; font-size: 12px; }

.sidebar nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; margin-bottom: 3px;
    border-radius: 9px;
    color: #c7d2fe; font-size: 14px; text-decoration: none;
}
.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.mi { width: 20px; text-align: center; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.logout {
    display: block; text-align: center; padding: 9px;
    background: rgba(255, 255, 255, .08); color: #fecaca;
    border-radius: 9px; font-size: 14px;
}
.logout:hover { background: var(--red); color: #fff; text-decoration: none; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 22px;
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.burger { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; }
.me { display: flex; align-items: center; gap: 10px; }
.me-txt { text-align: right; line-height: 1.2; }
.me-txt strong { font-size: 14px; display: block; }
.me-txt small { color: var(--muted); font-size: 12px; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 700;
}

.main { padding: 22px; flex: 1; }
.foot { padding: 14px 22px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }

/* ---------------- Card ---------------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-head {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 16px; flex: 1; }
.card-body { padding: 18px; }
.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }

/* ---------------- Stats ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 14px;
}
.stat .ic { font-size: 26px; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); }
.stat .val { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl td.num, table.tbl th.num { text-align: center; white-space: nowrap; }
table.tbl td.act { white-space: nowrap; text-align: right; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* ---------------- Form ---------------- */
label.lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=file], select, textarea {
    width: 100%; padding: 9px 11px;
    border: 1px solid #cbd5e1; border-radius: 9px;
    font: inherit; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(67, 56, 202, .12);
}
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.check input { width: auto; }

/* ---------------- Button ---------------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 15px; border: 1px solid transparent; border-radius: 9px;
    background: var(--primary); color: #fff; font: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-light { background: #fff; color: var(--text); border-color: #cbd5e1; }
.btn-light:hover { background: #f1f5f9; color: var(--text); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--green); }
.btn-success:hover { background: #047857; }
.btn-warn { background: var(--amber); }
.btn-warn:hover { background: #b45309; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Badge & alert ---------------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-green { background: var(--green-soft); color: #065f46; }
.badge-red { background: var(--red-soft); color: #991b1b; }
.badge-amber { background: var(--amber-soft); color: #92400e; }
.badge-blue { background: var(--blue-soft); color: #1e40af; }

.alert { padding: 12px 15px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: var(--green-soft); color: #065f46; border-color: #a7f3d0; }
.alert-danger  { background: var(--red-soft); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--amber-soft); color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--blue-soft); color: #1e40af; border-color: #bfdbfe; }

/* ---------------- Login ---------------- */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: linear-gradient(135deg, #312e81 0%, #4338ca 50%, #6d28d9 100%);
}
.auth-card {
    width: 100%; max-width: 400px; background: #fff;
    border-radius: 18px; padding: 30px; box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .5);
}
.auth-card h1 { margin: 0 0 4px; font-size: 21px; text-align: center; }
.auth-card p.sub { margin: 0 0 22px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-logo { font-size: 40px; text-align: center; }
.auth-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------------- Halaman ujian siswa ---------------- */
.exam-body { background: #f8fafc; }
.exam-top {
    position: sticky; top: 0; z-index: 30; background: var(--sidebar); color: #fff;
    padding: 10px 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.exam-top .judul { flex: 1; min-width: 180px; }
.exam-top .judul strong { display: block; font-size: 15px; }
.exam-top .judul small { color: #a5b4fc; }
.timer {
    background: #fff; color: var(--primary-dark); font-weight: 700; font-variant-numeric: tabular-nums;
    padding: 7px 14px; border-radius: 10px; font-size: 19px;
}
.timer.warn { background: var(--amber-soft); color: #92400e; }
.timer.danger { background: var(--red); color: #fff; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }

.exam-wrap { display: grid; grid-template-columns: 1fr 260px; gap: 18px; padding: 18px; align-items: start; }
.q-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.q-head { padding: 12px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.q-head .no { font-weight: 700; }
.q-body { padding: 18px; }
.q-text { font-size: 16px; margin-bottom: 16px; }
.q-text img { max-width: 100%; height: auto; }
.q-item { display: none; }
.q-item.active { display: block; }

.opt {
    display: flex; gap: 11px; align-items: flex-start;
    border: 1.5px solid var(--border); border-radius: 10px;
    padding: 11px 14px; margin-bottom: 9px; cursor: pointer; background: #fff;
}
.opt:hover { border-color: #a5b4fc; background: #f8faff; }
.opt input { margin-top: 4px; width: auto; }
.opt.picked { border-color: var(--primary); background: var(--primary-soft); }
.opt .huruf { font-weight: 700; }

.nav-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); position: sticky; top: 74px; }
.nav-card h3 { margin: 0; padding: 12px 15px; font-size: 14px; border-bottom: 1px solid var(--border); }
.qnums { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; padding: 15px; }
.qnum {
    aspect-ratio: 1; border: 1.5px solid #cbd5e1; border-radius: 8px; background: #fff;
    font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted);
    display: grid; place-items: center;
}
.qnum:hover { border-color: var(--primary); }
.qnum.answered { background: var(--green); border-color: var(--green); color: #fff; }
.qnum.doubt { background: var(--amber); border-color: var(--amber); color: #fff; }
.qnum.current { outline: 3px solid #a5b4fc; outline-offset: 1px; }
.legend { padding: 0 15px 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; margin-right: 10px; }
.dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.nav-foot { padding: 13px 15px; border-top: 1px solid var(--border); }
.save-state { font-size: 12px; color: var(--muted); min-height: 18px; }

.warn-banner {
    background: var(--red-soft); color: #991b1b; border: 1px solid #fecaca;
    padding: 11px 16px; font-size: 14px; text-align: center;
}

/* Overlay peringatan pindah tab */
.kick-overlay {
    position: fixed; inset: 0; z-index: 999; display: none;
    background: rgba(15, 23, 42, .93); color: #fff;
    place-items: center; text-align: center; padding: 24px;
}
.kick-overlay.show { display: grid; }
.kick-overlay .box { max-width: 440px; }
.kick-overlay h2 { font-size: 22px; margin: 12px 0; }
.kick-overlay .btn { margin-top: 8px; }

/* Ikon alarm berdenyut saat siswa dikeluarkan */
.kick-ikon { font-size: 62px; animation: alarm-denyut .7s ease-in-out infinite; }
@keyframes alarm-denyut {
    0%, 100% { transform: scale(1); filter: none; }
    50% { transform: scale(1.18); filter: drop-shadow(0 0 16px rgba(220, 38, 38, .95)); }
}
#kick-overlay.show { background: rgba(69, 10, 10, .95); animation: alarm-kilat 1.1s steps(2) infinite; }
@keyframes alarm-kilat {
    50% { background: rgba(15, 23, 42, .95); }
}

/* ---------------- Utility ---------------- */
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; } .mt16 { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.mono { font-family: Consolas, "Courier New", monospace; }
.token-code { font-family: Consolas, monospace; font-size: 17px; font-weight: 700; letter-spacing: .12em; }
.nilai-besar { font-size: 42px; font-weight: 800; line-height: 1; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 18px; flex-wrap: wrap; }
.tabs a { padding: 11px 14px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; text-decoration: none; }

@media (max-width: 900px) {
    .exam-wrap { grid-template-columns: 1fr; }
    .nav-card { position: static; }
}
@media (max-width: 780px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .22s; }
    .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    .burger { display: block; }
    .me-txt { display: none; }
    .main { padding: 16px; }
}

@media print {
    .sidebar, .topbar, .foot, .btn, .no-print { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { background: #fff; }
}
