/* =========================================================
   SIABSEN — Design tokens
   Palet terinspirasi papan tulis kelas & buku rapor:
   hijau tua sebagai warna utama, aksen status yang jelas.
   ========================================================= */
:root {
    --ink:        #16302B;   /* hijau papan tulis tua - sidebar & heading */
    --ink-soft:   #24463E;   /* hover state di atas ink */
    --paper:      #F6F7F5;   /* latar halaman, putih sejuk (bukan cream) */
    --surface:    #FFFFFF;
    --line:       #E3E7E3;   /* garis tipis pemisah kartu */
    --text:       #1E2521;
    --text-muted: #66756E;

    --teal:       #1F8A72;   /* Hadir / aksen utama */
    --teal-dark:  #146A57;
    --amber:      #E2A63B;   /* Sakit */
    --blue:       #3E6AE1;   /* Izin */
    --coral:      #E1584B;   /* Alpa / danger */

    --radius-card: 14px;
    --radius-sm: 8px;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--paper);
    margin: 0;
    color: var(--text);
    font-size: .95rem;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-body); font-weight: 700; color: var(--ink); }

a { color: var(--teal-dark); }
a:hover { color: var(--teal); }

:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

.app-wrapper { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 254px;
    background: var(--ink);
    color: #C9D6D1;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    transition: transform .28s ease;
    z-index: 1030;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 11px;
    padding: 24px 22px 20px;
    font-family: var(--font-display);
    font-weight: 600; font-size: 1.4rem;
    color: #fff;
    letter-spacing: .01em;
}
.sidebar-brand i { color: var(--teal); font-size: 1.3rem; }
.sidebar-nav { padding: 6px 12px 20px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    color: #B7C4BE; text-decoration: none;
    padding: 10px 14px; font-size: .89rem; font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .15s ease, color .15s ease;
}
.sidebar-nav a i { width: 18px; text-align: center; opacity: .85; font-size: .95rem; }
.sidebar-nav a:hover { background: var(--ink-soft); color: #fff; }
.sidebar-nav a.active {
    background: var(--teal);
    color: #fff;
    font-weight: 600;
}
.sidebar-nav a.active i { opacity: 1; }
.sidebar-section-title {
    font-size: .72rem; font-weight: 600;
    color: #6E8078; padding: 16px 14px 6px;
}
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(10, 20, 17, .45);
    z-index: 1020;
}

/* ---------- Main content ---------- */
.main-content { margin-left: 254px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--surface);
    padding: 14px 26px;
    display: flex; align-items: center; gap: 16px;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 900;
}
.btn-toggle {
    border: none; background: none; font-size: 1.15rem; color: var(--ink);
    display: none; cursor: pointer; width: 34px; height: 34px; border-radius: var(--radius-sm);
}
.btn-toggle:hover { background: var(--paper); }
.topbar-title { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: .87rem; }
.avatar-circle {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--teal); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.content-area { padding: 24px 26px 40px; flex: 1; }

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: none;
    background: var(--surface);
}

/* Stat cards: garis aksen kiri berwarna status, angka besar bergaya serif */
.stat-card {
    border-radius: var(--radius-card);
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--teal);
    position: relative;
    display: flex; flex-direction: column; gap: 2px;
    color: var(--text);
}
.stat-card i.bg-icon { position: absolute; right: 16px; top: 16px; font-size: 1.3rem; opacity: .35; color: var(--text-muted); }
.stat-card h3 {
    font-family: var(--font-display);
    font-size: 2rem; font-weight: 600; margin: 0 0 2px; line-height: 1;
    color: var(--ink);
}
.stat-card span.label { font-size: .82rem; color: var(--text-muted); font-weight: 500; }

.stat-clickable { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.stat-clickable:hover, .stat-clickable:focus-visible { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); outline: none; }

.stat-blue  { border-left-color: var(--blue); }
.stat-green { border-left-color: var(--teal); }
.stat-orange{ border-left-color: var(--amber); }
.stat-red   { border-left-color: var(--coral); }

.card-title-section {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.card-title-section h5 { font-weight: 700; margin: 0; font-size: 1.02rem; }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .87rem; padding: .5rem 1rem; }
.btn-primary { background: var(--teal); border-color: var(--teal); }
.btn-primary:hover, .btn-primary:focus { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-outline-primary { color: var(--teal-dark); border-color: var(--teal); }
.btn-outline-primary:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-outline-success { color: var(--teal-dark); border-color: var(--teal); }
.btn-outline-success:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-sm { font-size: .8rem; }

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--line);
    font-size: .89rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 .18rem rgba(31,138,114,.15);
}
.form-label { font-weight: 600; font-size: .85rem; color: var(--ink); margin-bottom: 5px; }

/* ---------- Tables ---------- */
.table { font-size: .88rem; }
.table thead th {
    font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); font-weight: 700;
    border-bottom-width: 1px; white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-responsive { border-radius: var(--radius-sm); }

/* ---------- Badges ---------- */
.badge { font-weight: 600; font-size: .74rem; padding: .4em .65em; border-radius: 6px; }

/* ---------- Nav tabs (laporan) ---------- */
.nav-tabs { border-bottom-color: var(--line); flex-wrap: nowrap; overflow-x: auto; }
.nav-tabs .nav-link {
    color: var(--text-muted); font-weight: 600; font-size: .87rem;
    border: none; border-bottom: 2px solid transparent; white-space: nowrap;
}
.nav-tabs .nav-link.active { color: var(--teal-dark); border-bottom-color: var(--teal); background: none; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); border: 1px solid transparent; font-size: .88rem; }

/* =========================================================
   LOGIN PAGE — split screen
   ========================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--paper);
}
.login-hero {
    flex: 1.1;
    background: var(--ink);
    color: #fff;
    padding: 56px 52px;
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.login-hero::before {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(circle at 30% 30%, black 0%, transparent 70%);
    pointer-events: none;
}
.login-hero-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; position: relative; z-index: 1; }
.login-hero-brand i { color: var(--teal); }
.login-hero h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.9rem, 3.4vw, 2.7rem);
    color: #fff; line-height: 1.15; max-width: 15ch;
    position: relative; z-index: 1;
}
.login-hero p { color: #A9BAB3; max-width: 38ch; font-size: .95rem; position: relative; z-index: 1; }
.login-hero-foot { color: #7F978D; font-size: .8rem; position: relative; z-index: 1; }

.login-form-panel {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 40px 32px;
}
.login-form-box { width: 100%; max-width: 360px; }
.login-form-box h4 { font-weight: 700; margin-bottom: 4px; }
.login-form-box .sub { color: var(--text-muted); font-size: .88rem; margin-bottom: 26px; }

@media (max-width: 900px) {
    .login-page { flex-direction: column; }
    .login-hero { padding: 32px 28px; flex: none; min-height: 190px; }
    .login-hero h1 { max-width: none; font-size: 1.6rem; }
    .login-hero p { display: none; }
    .login-form-panel { padding: 32px 24px 48px; }
}

/* =========================================================
   RESPONSIVE — sidebar & layout for tablet/mobile
   ========================================================= */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
    .btn-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .content-area { padding: 18px 16px 32px; }
    .topbar { padding: 12px 16px; }
    .topbar-title { font-size: .95rem; }
}

@media (max-width: 576px) {
    .stat-card h3 { font-size: 1.6rem; }
    .card { border-radius: 12px; }
    .content-area { padding: 14px 12px 28px; }
    .topbar-user span { display: none; }
    .card-title-section { align-items: flex-start; }
    .card-title-section .d-flex { width: 100%; }
}

@media print {
    .sidebar, .sidebar-overlay, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { border: 1px solid #ccc; }
    body { background: #fff; }
}

/* =========================================================
   NOTIFIKASI SURAT ORANG TUA
   ========================================================= */
.nav-badge {
    margin-left: auto; background: var(--coral); color: #fff;
    font-size: .7rem; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
}
.topbar-bell {
    position: relative; width: 38px; height: 38px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--ink); text-decoration: none; font-size: 1.1rem;
}
.topbar-bell:hover { background: var(--paper); color: var(--ink); }
.topbar-bell + .topbar-user { margin-left: 4px; }
.bell-count {
    position: absolute; top: 2px; right: 0;
    background: var(--coral); color: #fff; font-size: .65rem; font-weight: 700;
    min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--surface);
}
.bell-ring { animation: bellRing .9s ease; }
@keyframes bellRing { 0%,100%{transform:rotate(0)} 20%{transform:rotate(14deg)} 40%{transform:rotate(-12deg)} 60%{transform:rotate(8deg)} 80%{transform:rotate(-5deg)} }
.surat-banner { border-left: 4px solid var(--amber); background: #FFF8E6; border-color: #F3DFAE; }
.surat-alasan { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .9rem; white-space: pre-wrap; }
.toast-container-fixed { position: fixed; right: 16px; bottom: 16px; z-index: 2000; }

/* =========================================================
   PORTAL ORANG TUA (mobile-first)
   ========================================================= */
.ortu-top {
    background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 900;
}
.ortu-top-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.ortu-brand { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; }
.ortu-brand i { color: var(--teal); }
.ortu-top a.ortu-link { color: #C9D6D1; text-decoration: none; font-size: .85rem; font-weight: 500; padding: 6px 10px; border-radius: var(--radius-sm); }
.ortu-top a.ortu-link:hover, .ortu-top a.ortu-link.active { background: var(--ink-soft); color: #fff; }
.ortu-wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
.ortu-hero { background: var(--ink); color: #fff; border-radius: var(--radius-card); padding: 20px 22px; position: relative; overflow: hidden; }
.ortu-hero h2 { font-family: var(--font-display); color: #fff; font-size: 1.45rem; font-weight: 600; margin: 0 0 2px; }
.ortu-hero .meta { color: #A9BAB3; font-size: .86rem; }
.mini-stat { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: var(--radius-sm); padding: 10px 12px; }
.mini-stat b { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; display: block; line-height: 1.1; color: var(--ink); }
.mini-stat span { font-size: .75rem; color: var(--text-muted); font-weight: 500; }
.surat-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface); }
.surat-item + .surat-item { margin-top: 10px; }
.jenis-pilih { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.jenis-pilih input { position: absolute; opacity: 0; pointer-events: none; }
.jenis-pilih label {
    border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 14px 12px; cursor: pointer;
    text-align: center; font-weight: 600; background: var(--surface); transition: border-color .15s, background .15s;
}
.jenis-pilih label i { display: block; font-size: 1.3rem; margin-bottom: 4px; color: var(--text-muted); }
.jenis-pilih input:checked + label { border-color: var(--teal); background: #EAF6F2; color: var(--teal-dark); }
.jenis-pilih input:checked + label i { color: var(--teal); }
.jenis-pilih input:focus-visible + label { outline: 2px solid var(--teal); outline-offset: 2px; }
@media (max-width: 576px) {
    .ortu-wrap { padding: 14px 12px 40px; }
    .ortu-top a.ortu-link span { display: none; }
}


/* =========================================================
   Kartu Pelajar & Scan Absensi
   ========================================================= */
.thumb-foto { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.thumb-kosong { background: #dfe8e3; color: #5f7f73; font-weight: 700; font-size: .85rem; }
.foto-form-preview { width: 84px; height: 112px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: #eef2ef; display: flex; align-items: center; justify-content: center; color: #86a196; font-size: 2rem; font-weight: 700; overflow: hidden; }
.foto-form-preview img { width: 100%; height: 100%; object-fit: cover; }

.scan-bar { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 14px 20px; margin-bottom: 16px; }
.scan-tanggal { font-size: .82rem; color: var(--text-muted); }
.scan-jam { font-size: 1.9rem; font-weight: 700; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.scan-statistik { display: flex; gap: 26px; margin-left: 6px; }
.scan-statistik > div { display: flex; flex-direction: column; line-height: 1.15; }
.scan-statistik span { font-size: 1.55rem; font-weight: 700; color: var(--teal-dark); font-variant-numeric: tabular-nums; }
.scan-statistik small { color: var(--text-muted); font-size: .78rem; }
.scan-aturan { margin-left: auto; font-size: .8rem; color: var(--text-muted); text-align: right; line-height: 1.5; }

.scan-kamera { position: relative; background: #0f1a17; border-radius: 12px; overflow: hidden; min-height: 280px; }
#reader { width: 100%; border: none !important; }
#reader video { object-fit: cover; }
.scan-kamera-kosong { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #7fa294; font-size: .9rem; pointer-events: none; }
.scan-kamera-kosong i { font-size: 2.6rem; }

.scan-hasil { min-height: 340px; height: 100%; border-radius: 12px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; background: var(--paper); border: 1.5px dashed var(--line); color: var(--text); transition: background-color .18s ease, color .18s ease; }
.scan-hasil-diam i { font-size: 3rem; color: #a9b8b1; margin-bottom: 10px; }
.scan-hasil[data-tipe="ok"]   { background: var(--teal);  border: 1.5px solid var(--teal-dark); color: #fff; }
.scan-hasil[data-tipe="warn"] { background: var(--amber); border: 1.5px solid #c58a1f; color: #2b2100; }
.scan-hasil[data-tipe="info"] { background: var(--blue);  border: 1.5px solid #2f55bd; color: #fff; }
.scan-hasil[data-tipe="bad"]  { background: var(--coral); border: 1.5px solid #bd4236; color: #fff; }
.scan-hasil-isi { width: 100%; animation: scan-muncul .16s ease-out; }
.scan-status { font-size: 1.9rem; font-weight: 800; line-height: 1.15; margin-bottom: 16px; }
.scan-foto { width: 128px; height: 128px; margin: 0 auto 12px; border-radius: 50%; overflow: hidden; background: rgba(255,255,255,.28); display: flex; align-items: center; justify-content: center; font-size: 3.2rem; font-weight: 700; }
.scan-foto img { width: 100%; height: 100%; object-fit: cover; }
.scan-nama { font-size: 1.5rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.scan-kelas { opacity: .92; margin-top: 2px; }
.scan-pesan { margin-top: 14px; font-size: 1.02rem; }
@keyframes scan-muncul { from { transform: scale(.97); opacity: .4; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .scan-hasil-isi { animation: none; } .scan-hasil { transition: none; } }

.scan-keluar-penuh { display: none; position: fixed; left: 16px; bottom: 16px; z-index: 1500; align-items: center; background: rgba(22,48,43,.92); color: #fff; border: 0; border-radius: 999px; padding: 9px 16px; font-size: .85rem; }
body.mode-kios .sidebar, body.mode-kios .topbar, body.mode-kios .sidebar-overlay { display: none !important; }
body.mode-kios .main-content { margin-left: 0; }
body.mode-kios .scan-keluar-penuh { display: inline-flex; }
body.mode-kios .scan-hasil { min-height: 420px; }

@media (max-width: 768px) {
    .scan-bar { gap: 14px; }
    .scan-aturan { margin-left: 0; text-align: left; }
    .scan-statistik { margin-left: 0; }
    .scan-status { font-size: 1.5rem; }
}


/* =========================================================
   Pengaturan Sistem: logo & nama sekolah di sidebar/login/portal
   ========================================================= */
.brand-logo { width: 34px; height: 34px; object-fit: contain; flex: none; border-radius: 8px; background: rgba(255,255,255,.96); padding: 3px; }
.sidebar-brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-school { margin: -12px 22px 14px; font-size: .74rem; line-height: 1.35; color: #8FA79E; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.login-hero-brand .brand-logo { width: 38px; height: 38px; }
.ortu-brand .brand-logo { width: 28px; height: 28px; padding: 2px; border-radius: 6px; }
.logo-pratinjau { width: 76px; height: 76px; flex: none; border-radius: 14px; border: 1px dashed var(--line); background: var(--paper); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--teal); font-size: 1.9rem; }
.logo-pratinjau img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.pratinjau-sidebar { background: var(--ink); border-radius: 12px; padding: 16px 18px; color: #fff; }
.pratinjau-sidebar .sidebar-brand { color: #fff; }
.pratinjau-sidebar .sidebar-school { margin: 2px 0 0; }
