/* style.css - tampilan bersama Praktikum Data Sains (tanpa CDN, tanpa framework) */

:root {
    --bg: #f3f5f9;
    --panel: #ffffff;
    --panel-alt: #f8fafc;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --brand: #1d4ed8;
    --brand-dark: #172554;
    --teal: #0f766e;
    --ok: #15803d;
    --ok-bg: #dcfce7;
    --warn: #b45309;
    --warn-bg: #fef3c7;
    --bad: #b91c1c;
    --bad-bg: #fee2e2;
    --info: #1d4ed8;
    --info-bg: #dbeafe;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

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

.mono, code, pre {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
}

/* ---------- Skip link ---------- */
.skip {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand);
    color: #fff;
    padding: .5rem 1rem;
    z-index: 100;
}
.skip:focus { left: 0; }

/* ---------- Kerangka ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--brand-dark);
    color: #fff;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand { margin-bottom: 1.5rem; padding: 0 .5rem; }
.sidebar .brand strong { display: block; font-size: 1.1rem; }
.sidebar .brand span { font-size: .85rem; opacity: .75; }

.nav { list-style: none; margin: 0; padding: 0; }
.nav li { margin-bottom: .25rem; }
.nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .6rem;
    border-radius: 8px;
    color: #dbeafe;
    font-size: .92rem;
    line-height: 1.3;
}
.nav a:hover { background: rgba(255, 255, 255, .1); text-decoration: none; }
.nav a[aria-current="page"] { background: #fff; color: var(--brand-dark); font-weight: 600; }
.nav .no {
    width: 1.7rem;
    height: 1.7rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, .15);
    font-size: .8rem;
    font-weight: 700;
}
.nav a[aria-current="page"] .no { background: var(--brand); color: #fff; }

.side-foot { margin-top: auto; padding: 1.5rem .5rem 0; font-size: .78rem; opacity: .7; }

.main { flex: 1; min-width: 0; padding: 2rem 2.5rem; max-width: 1100px; }
.main h1 { margin: 0 0 .4rem; font-size: 1.8rem; color: var(--brand-dark); line-height: 1.25; }
.lead { color: var(--muted); margin: 0 0 1.5rem; }

/* ---------- Panel perintah soal ---------- */
.brief {
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}
.brief summary { cursor: pointer; padding: .8rem 1rem; font-weight: 600; }
.brief-body { padding: 0 1rem 1rem; }
.brief-body p { margin: 0 0 .5rem; }
.brief-body ul { margin: .25rem 0 0; padding-left: 1.2rem; }

/* ---------- Beranda: daftar soal ---------- */
.tasklist { list-style: none; margin: 0 0 2rem; padding: 0; display: grid; gap: .8rem; }
.task {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    color: inherit;
}
.task:hover { border-color: var(--brand); text-decoration: none; box-shadow: 0 2px 8px rgba(29, 78, 216, .12); }
.task .no {
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
}
.task h2 { margin: 0 0 .15rem; font-size: 1.05rem; color: var(--brand-dark); }
.task p { margin: 0 0 .25rem; color: var(--muted); font-size: .9rem; }
.task .badge { margin-left: auto; white-space: nowrap; }

/* ---------- Badge ---------- */
.badge {
    display: inline-block;
    padding: .12rem .6rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: #e2e8f0;
    color: #334155;
}
.badge.ok   { background: var(--ok-bg);   color: #166534; }
.badge.warn { background: var(--warn-bg); color: #92400e; }
.badge.bad  { background: var(--bad-bg);  color: #991b1b; }
.badge.info { background: var(--info-bg); color: #1e40af; }

/* ---------- Kartu angka ---------- */
.figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .8rem;
    margin-bottom: 1.5rem;
}
.figure {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    min-width: 0;
}
.figure .label { font-size: .8rem; color: var(--muted); }
.figure .value { font-size: 1.7rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.figure .value.small { font-size: 1.05rem; padding-top: .3rem; }
.figure .value.brand { color: var(--brand); }
.figure .value.ok    { color: var(--ok); }
.figure .value.bad   { color: var(--bad); }
.figure .value.teal  { color: var(--teal); }
.figure .hint { font-size: .78rem; color: var(--muted); }

/* ---------- Panel ---------- */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--panel-alt);
}
.panel > header h2 { margin: 0; font-size: 1.05rem; }
.panel .note { font-size: .82rem; color: var(--muted); }
.panel .body { padding: 1rem; }

/* ---------- Tahapan pipeline (soal 1) ---------- */
.stages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.stage {
    padding: 1rem;
    text-align: center;
    border-right: 1px solid var(--border);
}
.stage:last-child { border-right: 0; }
.stage .count { font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1.2; }
.stage .name { font-weight: 600; }
.stage .desc { font-size: .8rem; color: var(--muted); }

/* ---------- Tabel ---------- */
.table-wrap, .scroll { overflow-x: auto; }
.scroll { max-height: 380px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .55rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--panel-alt); font-weight: 600; white-space: nowrap; }
.scroll th { position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { background: var(--panel-alt); font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.wrap { min-width: 220px; }
tr.is-bad td { background: #fff5f5; }
td.filled { background: var(--warn-bg); font-weight: 600; }
.empty { color: var(--bad); font-style: italic; }

/* ---------- Alert ---------- */
.alert {
    padding: .8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}
.alert.info { background: var(--info-bg); color: #1e3a8a; border-color: #bfdbfe; }
.alert.bad  { background: var(--bad-bg);  color: #7f1d1d; border-color: #fecaca; }

/* ---------- Langkah perhitungan (soal 3) ---------- */
.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: .8rem;
    margin-bottom: 1.5rem;
}
.step {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    min-width: 0;
}
.step h3 { margin: 0 0 .25rem; font-size: 1rem; color: var(--brand-dark); }
.step p { margin: 0 0 .6rem; font-size: .88rem; color: var(--muted); }

pre.codeblock {
    margin: 0;
    padding: .75rem 1rem;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .85rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.body > pre.codeblock { white-space: pre-wrap; }

/* Meter skala 0 sampai 1 */
.meter { width: 140px; height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* ---------- ASCII bar chart (soal 4) ---------- */
pre.terminal {
    margin: 0;
    padding: 1rem 1.2rem;
    background: #0f172a;
    color: #e2e8f0;
    font-size: .95rem;
    line-height: 1.7;
    overflow-x: auto;
}
pre.terminal .bar { color: #34d399; }
pre.terminal .dim { color: #94a3b8; }

/* ---------- Form input (soal 4) ---------- */
.form-data label { display: block; font-weight: 600; margin-bottom: .35rem; }
.form-data textarea {
    width: 100%;
    min-height: 80px;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .9rem;
    resize: vertical;
}
.form-data .actions { display: flex; gap: .6rem; margin-top: .6rem; flex-wrap: wrap; }
.form-data .hint { font-size: .8rem; color: var(--muted); margin-top: .4rem; }

/* ---------- Train-test split (soal 5) ---------- */
.split-legend { display: flex; gap: 1.2rem; font-size: .85rem; margin-bottom: .5rem; flex-wrap: wrap; }
.split-legend .t1::before, .split-legend .t2::before {
    content: "";
    display: inline-block;
    width: .75rem;
    height: .75rem;
    border-radius: 3px;
    margin-right: .4rem;
    vertical-align: -1px;
}
.split-legend .t1::before { background: var(--brand); }
.split-legend .t2::before { background: var(--teal); }

.split { display: flex; height: 2.2rem; border-radius: 8px; overflow: hidden; font-weight: 700; color: #fff; }
.split > div { display: flex; align-items: center; justify-content: center; min-width: 0; }
.split .train { background: var(--brand); }
.split .test  { background: var(--teal); }

.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; margin-top: 1rem; }
.check {
    padding: .7rem .9rem;
    border: 1px solid #fecaca;
    background: var(--bad-bg);
    border-radius: 8px;
    font-size: .85rem;
    color: #7f1d1d;
}
.check b { display: block; font-size: 1rem; }
.check.ok { border-color: #bbf7d0; background: var(--ok-bg); color: #14532d; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }

/* ---------- Tombol & navigasi bawah ---------- */
.btn {
    display: inline-block;
    padding: .5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--brand-dark);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary, .btn.next { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; flex-wrap: wrap; }
.pager .next { margin-left: auto; }

/* ---------- Responsif ---------- */
@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .main { padding: 1.25rem; }
    .task { flex-wrap: wrap; }
    .stage { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* ---------- Dashboard realtime ---------- */
.live-bar {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem 1rem;
    margin-bottom: 1rem;
}
.live-bar .btn { margin-left: auto; padding: .3rem .8rem; }
.dot { width: .7rem; height: .7rem; border-radius: 50%; background: #94a3b8; flex-shrink: 0; }
.dot.on  { background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: denyut 1.6s infinite; }
.dot.off { background: var(--bad); }
@keyframes denyut {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
    70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.feed { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow-y: auto; }
.feed li {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: .88rem;
}
.feed li:last-child { border-bottom: 0; }
.feed .teks { flex: 1; min-width: 0; }
.feed li.baru { animation: sorot 2.5s ease-out; }
.empty-row { color: var(--muted); font-style: italic; padding: .8rem 1rem; }
td.empty-row { text-align: center; }

.flash { animation: sorot-angka 1.2s ease-out; }
@keyframes sorot { from { background: var(--warn-bg); } to { background: transparent; } }
@keyframes sorot-angka { from { color: var(--warn); transform: scale(1.12); } to { transform: none; } }

.db-note a { font-weight: 600; margin-left: .4rem; }
.split-legend + .split, .body > .split { margin-bottom: .6rem; }

/* ---------- CRUD, reset, dan form (ditambahkan) ---------- */
.alert.ok   { background: var(--ok-bg);   color: #14532d; border-color: #bbf7d0; }
.alert.warn { background: var(--warn-bg); color: #78350f; border-color: #fde68a; }

.btn.sm { padding: .25rem .6rem; font-size: .8rem; }
.btn.block { display: block; width: 100%; }
.btn.danger { color: var(--bad); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.primary:hover { background: #1e40af; }
form.inline { display: inline; margin: 0; }

.side-reset { margin-top: 1.25rem; padding: 0 .5rem; }
.side-reset small { display: block; margin-top: .4rem; font-size: .72rem; opacity: .7; line-height: 1.4; }
.side-reset .btn.danger { background: rgba(255, 255, 255, .08); color: #fecaca; border-color: rgba(254, 202, 202, .5); }
.side-reset .btn.danger:hover { background: rgba(254, 202, 202, .2); }

.in {
    width: 100%;
    min-width: 70px;
    padding: .35rem .5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: .88rem;
    background: #fff;
    color: var(--text);
}
.in:focus { outline: 2px solid var(--info-bg); border-color: var(--brand); }
table td .in { margin: -.1rem 0; }
td.aksi { white-space: nowrap; width: 1%; }

.crud-add {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: flex-end;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fbff;
}
.crud-add label { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: .15rem; }
.crud-add .fld { flex: 1 1 130px; min-width: 110px; }
.crud-add .fld.kecil { flex: 0 1 90px; min-width: 80px; }
.crud-tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.crud-hint { padding: .6rem 1rem; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--border); background: var(--panel-alt); }
.ctrl-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.ctrl-bar select { padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.live-bar form.inline .btn { margin-left: 0; }
.panel > header .link { font-size: .82rem; font-weight: 600; }
