/* ==========================================================================
   app.css — Absensi MI (refined / crafted UI)
   ========================================================================== */

:root {
    --ink: #0b1220;
    --ink-soft: #111827;
    --paper: #ffffff;
    --canvas: #f4f6f3;
    --canvas-warm: #eef3ee;

    --brand: #0f766e;
    --brand-deep: #115e59;
    --brand-dark: #134e4a;
    --brand-bright: #14b8a6;
    --brand-soft: #e6fffa;
    --brand-tint: #f0fdfa;

    --accent: #c2410c;
    --accent-soft: #fff7ed;

    --line: #dde5df;
    --line-strong: #c9d6ce;
    --muted: #5f6f67;
    --muted-2: #7b8a83;

    --ok: #15803d;
    --ok-bg: #ecfdf3;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --info: #1d4ed8;
    --info-bg: #eff6ff;

    --r-sm: 10px;
    --r: 14px;
    --r-lg: 18px;

    --shadow-1: 0 1px 0 rgba(17,24,39,.04), 0 8px 24px rgba(17,24,39,.04);
    --shadow-2: 0 1px 0 rgba(17,24,39,.04), 0 16px 40px rgba(17,24,39,.08);
    --sidebar-w: 270px;
}

html, body { height: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, #f7f9f7 0%, var(--canvas) 100%);
    font-family: "Avenir Next", "Segoe UI Variable", "Segoe UI", "Trebuchet MS", "Noto Sans", sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: #99f6e4; color: #042f2e; }

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

/* subtle grain */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .35;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
    z-index: 0;
}

.app-shell, .login-page { position: relative; z-index: 1; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.app-main {
    flex: 1 1 auto;
    padding: 1.4rem 1rem 2.5rem;
}

@media (min-width: 768px) {
    .app-main { padding: 1.75rem 2rem 3rem; }
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: #0f1f1c;
    color: #e7f3ee;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 1045;
    border-right: 1px solid rgba(255,255,255,.04);
}

body.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(11, 18, 32, .5);
    z-index: 1040;
}
body.sidebar-open .sidebar-backdrop { display: block; }

.sidebar-brand {
    padding: 1.2rem 1.2rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.sidebar-brand-link {
    display: flex; align-items: center; gap: .85rem;
    text-decoration: none; color: #fff;
    flex: 1 1 auto;
    min-width: 0;
}

.brand-text { min-width: 0; }

.sidebar-close {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    background: rgba(255,255,255,.04);
    color: #cfe3dc;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.sidebar-close:hover,
.sidebar-close:focus-visible {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.2);
    color: #fff;
}

.brand-logo {
    width: 42px; height: 42px; flex: 0 0 42px;
    display: grid; place-items: center;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,.35));
}

.brand-logo img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
}

.brand-title { font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.brand-sub { font-size: .7rem; color: #8fb8ad; letter-spacing: .08em; text-transform: uppercase; }

.sidebar-nav { padding: .7rem .55rem; flex: 1 1 auto; overflow-y: auto; }

.sidebar-label {
    padding: .65rem .8rem .3rem;
    font-size: .66rem; font-weight: 700;
    letter-spacing: .14em; text-transform: uppercase;
    color: #6f968b;
}

.sidebar .nav-link {
    display: flex; align-items: center; gap: .7rem;
    margin: .1rem 0;
    padding: .58rem .75rem;
    border-radius: 10px;
    color: #cfe3dc;
    font-size: .92rem; font-weight: 500;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
    position: relative;
}

.sidebar .nav-link i { font-size: 1.02rem; width: 1.2rem; text-align: center; color: #8fb8ad; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link:hover i { color: #cfe3dc; }

.sidebar .nav-link.active {
    background: #ecfdf5;
    color: #064e3b;
    font-weight: 600;
}
.sidebar .nav-link.active i { color: #0f766e; }
.sidebar .nav-link.active::before {
    content: "";
    position: absolute; left: -0.55rem; top: 22%; bottom: 22%;
    width: 3px; border-radius: 3px; background: #2dd4bf;
}

.sidebar-footer {
    padding: .9rem 1rem 1.05rem;
    border-top: 1px solid rgba(255,255,255,.07);
    font-size: .74rem; color: #86ada2;
}

.sidebar-user { display: flex; align-items: center; gap: .6rem; color: #e7f3ee; }
.sidebar-user .min-w-0 { min-width: 0; }

.avatar-circle {
    width: 36px; height: 36px; flex: 0 0 36px;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.1);
    display: grid; place-items: center;
    font-weight: 700; color: #fff;
}

@media (min-width: 992px) {
    .sidebar { position: sticky; transform: none; height: 100vh; top: 0; }
    .sidebar-backdrop { display: none !important; }
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .75rem 1rem;
    background: rgba(244, 246, 243, .85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

@media (min-width: 768px) { .topbar { padding: .8rem 2rem; } }

.topbar-title {
    font-size: 1.02rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.2;
}
.topbar-sub { font-size: .74rem; color: var(--muted); }

.avatar-sm {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 10px;
    background: var(--brand-tint);
    color: var(--brand-dark);
    border: 1px solid #99f6e4;
    display: grid; place-items: center;
    font-weight: 700;
}

/* ---------- Typography ---------- */
.section-title {
    font-size: 1.35rem;
    font-weight: 750;
    letter-spacing: -.03em;
    margin-bottom: .15rem;
    color: var(--ink);
}
.section-sub { font-size: .86rem; color: var(--muted); margin-bottom: 0; }

/* ---------- Cards ---------- */
.card { border-color: var(--line); }

.card-clean, .stat-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
}

.stat-card { height: 100%; position: relative; }
.stat-card .card-body { padding: 1rem 1.1rem 1.05rem; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 750;
    line-height: 1.05;
    letter-spacing: -.03em;
    color: var(--ink);
}
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; letter-spacing: .01em; }

.card-clean .card-header {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: .95rem 1.15rem;
    font-weight: 650;
    font-size: .93rem;
    letter-spacing: -.01em;
}
.card-clean .card-body { padding: 1.1rem 1.15rem; }

.info-tile {
    border-radius: 12px;
    background: #f8faf8;
    border: 1px solid var(--line);
    padding: .85rem 1rem;
}

/* ---------- Tables ---------- */
.table-responsive { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.table-clean { margin-bottom: 0; --bs-table-bg: transparent; }
.table-clean thead th {
    background: #f7faf8;
    color: #41524b;
    font-size: .7rem; font-weight: 700;
    letter-spacing: .1em; text-transform: uppercase;
    border-bottom: 1px solid var(--line);
    padding: .8rem 1rem;
    white-space: nowrap;
}
.table-clean td {
    padding: .85rem 1rem;
    border-color: #edf2ee;
    font-size: .9rem;
    color: #24312b;
}
.table-clean tbody tr:hover { background: #fbfdfb; }

/* ---------- Dashboard: tren & kehadiran kelas ---------- */
.chart-stack {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 132px;
}

.chart-col {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.chart-bar {
    height: 108px;
    width: 100%;
    display: flex;
    flex-direction: column-reverse;
    border-radius: 5px 5px 3px 3px;
    overflow: hidden;
    background: #f2f6f3;
}

.chart-bar-empty {
    background: #f7faf8;
    box-shadow: inset 0 -1px 0 #e3eae5;
}

.chart-seg { display: block; width: 100%; }
.chart-seg-hadir { background: #15803d; }
.chart-seg-sakit { background: #d97706; }
.chart-seg-izin  { background: #2563eb; }
.chart-seg-alpa  { background: #dc2626; }

.chart-day {
    margin-top: .3rem;
    text-align: center;
    font-size: .62rem;
    color: var(--muted-2);
    font-variant-numeric: tabular-nums;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .9rem;
    margin-top: .7rem;
    font-size: .72rem;
    color: var(--muted);
}

.chart-legend span { display: inline-flex; align-items: center; gap: .32rem; }

.chart-dot {
    width: 8px; height: 8px;
    border-radius: 2px;
    display: inline-block;
    flex: 0 0 8px;
}

.kelas-list { max-height: 340px; overflow-y: auto; }

.kelas-row { padding: .7rem 1.15rem; }
.kelas-row + .kelas-row { border-top: 1px solid #edf2ee; }

.att-bar {
    display: flex;
    height: 7px;
    border-radius: 99px;
    overflow: hidden;
    background: #edf2ef;
}

.att-bar > span { display: block; height: 100%; }
.att-hadir { background: #15803d; }
.att-sakit { background: #d97706; }
.att-izin  { background: #2563eb; }
.att-alpa  { background: #dc2626; }

.att-counts {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .55rem;
    font-size: .68rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.att-count-hadir { color: #15803d; }
.att-count-sakit { color: #b45309; }
.att-count-izin  { color: #1d4ed8; }
.att-count-alpa  { color: #b91c1c; }

.min-w-0 { min-width: 0; }

.siswa-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .65rem 1.15rem;
    text-decoration: none;
    color: inherit;
}

.siswa-row + .siswa-row { border-top: 1px solid #edf2ee; }
.siswa-row:hover { background: #f8fbf9; color: inherit; }

/* ---------- Buttons ---------- */
.btn {
    border-radius: 10px;
    font-weight: 600;
    font-size: .9rem;
    letter-spacing: -.005em;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { border-radius: 8px; font-size: .82rem; }

.btn-success {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-deep);
    --bs-btn-hover-border-color: var(--brand-deep);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
}
.btn-outline-success {
    --bs-btn-color: var(--brand-deep);
    --bs-btn-border-color: #5eead4;
    --bs-btn-hover-bg: var(--brand-tint);
    --bs-btn-hover-border-color: #2dd4bf;
    --bs-btn-hover-color: var(--brand-dark);
}
.btn-light { background: #fff; border-color: var(--line-strong); color: #334155; }
.btn-light:hover { background: #f8fafc; }

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--line-strong);
    padding: .58rem .8rem;
    color: var(--ink);
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-bright);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, .15);
}
.input-group-text {
    border-radius: 10px;
    border-color: var(--line-strong);
    background: #f8faf8;
    color: #475569;
}
.form-label { font-size: .86rem; font-weight: 600; color: #334155; margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* ---------- Alerts & badges ---------- */
.alert {
    border-radius: 12px;
    border: 1px solid transparent;
}
.alert-success { background: var(--ok-bg); color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warn-bg); color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--info-bg); color: #1e40af; border-color: #bfdbfe; }

.badge { border-radius: 7px; font-weight: 600; letter-spacing: .01em; padding: .4em .55em; }

/* ---------- Footer ---------- */
.app-footer {
    padding: .95rem 2rem;
    font-size: .77rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
    background: transparent;
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: #0f1f1c;
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: "";
    position: absolute; inset: 0;
    background:
        radial-gradient(800px 400px at 0% 0%, rgba(20,184,166,.18), transparent 60%),
        radial-gradient(600px 360px at 100% 100%, rgba(15,118,110,.22), transparent 55%);
    pointer-events: none;
}
.login-page::after {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 440px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0,0,0,.45);
    background: #ffffff;
    overflow: hidden;
}
.login-logo {
    width: 84px; height: 84px;
    display: grid; place-items: center;
    margin: 0 auto .95rem;
    filter: drop-shadow(0 10px 20px rgba(6,78,59,.18));
}

.login-logo img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
}
.login-footer { color: #9fb8b0; font-size: .77rem; text-align: center; margin-top: 1rem; }

.footer-logo {
    vertical-align: -3px;
    margin-right: .35rem;
    opacity: .95;
}

/* ---------- Dropdown ---------- */
.dropdown-menu {
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-2);
    padding: .35rem;
}
.dropdown-item { border-radius: 8px; padding: .48rem .65rem; }

/* ---------- Misc ---------- */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }

.bg-light-subtle { background-color: #f8faf8 !important; }
.border-warning-subtle { border-color: #fde68a !important; }
.text-bg-light.text-capitalize {
    background: #f1f5f9 !important; color: #334155 !important; border: 1px solid #e2e8f0;
}

.table > :not(caption) > * > * { box-shadow: none; }
hr { border-color: var(--line); opacity: 1; }

@media (max-width: 575.98px) {
    .section-title { font-size: 1.2rem; }
    .stat-value { font-size: 1.55rem; }
    .app-footer { padding: .9rem 1rem; }
}
