:root {
    /* Warna diambil dari logo SD Aisyiyah Metro: pink/magenta & cyan/turquoise */
    --primary: #d6006f;
    --primary-dark: #a80058;
    --primary-light: #ff4fa8;
    --secondary: #00acb8;
    --secondary-dark: #00838d;
    --secondary-light: #29d6e0;
    --sidebar-bg-1: #2b0a1e;
    --sidebar-bg-2: #7a0d4b;
    --accent: #e2001a;
    --success: #16a34a;
    --danger: #dc2626;
    --border: #e5e9f2;
    --bg-body: #f7f5f8;
    --text-muted: #6b7280;

    /* Override token warna Bootstrap agar komponen bawaan (mis. bg-primary-subtle) ikut tema sekolah */
    --bs-primary: #d6006f;
    --bs-primary-rgb: 214, 0, 111;
    --bs-primary-text-emphasis: #6a0038;
    --bs-primary-bg-subtle: #fbe4f0;
    --bs-primary-border-subtle: #f5b8d8;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-body);
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Roboto, Arial, sans-serif;
    color: #1f2430;
    margin: 0;
}

.icon { flex-shrink: 0; }

/* ===================== LOGIN ===================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7a0d4b 0%, #2b0a1e 45%, #00565e 100%);
    padding: 1.5rem;
}

.login-card {
    max-width: 400px;
    width: 100%;
    border: none;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.35);
    background: #fff;
    padding: 2.25rem 2rem;
}

.login-logo {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 20px rgba(214,0,111,.25);
    padding: 6px;
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; }

.demo-box {
    background: #f4f5fb;
    border-radius: 10px;
    padding: .75rem 1rem;
    font-size: .82rem;
    color: var(--text-muted);
}

/* ===================== APP SHELL / SIDEBAR ===================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 258px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg-1), var(--sidebar-bg-2));
    color: #d1d5db;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1030;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.3rem 1.4rem 1.1rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }

.brand-text-group { line-height: 1.2; overflow: hidden; }
.brand-title { font-weight: 800; font-size: .92rem; white-space: nowrap; }
.brand-subtitle { font-weight: 500; font-size: .72rem; color: rgba(255,255,255,.65); }

.sidebar-nav {
    flex: 1;
    padding: 1rem .8rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    overflow-y: auto;
}

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

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 999px;
    line-height: 1.4;
}

.bukti-preview img {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .55rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: .9rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-muted); }
.detail-row .value { font-weight: 600; text-align: right; }

/* ===================== KALENDER LAPORAN ===================== */
.calendar-table {
    width: 100%;
    min-width: 760px;
    border-collapse: separate;
    border-spacing: 6px;
    table-layout: fixed;
}
.calendar-table th {
    text-align: center;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    font-weight: 700;
    padding-bottom: .4rem;
}
.calendar-day {
    border: 1px solid var(--border);
    border-radius: 10px;
    height: 96px;
    padding: 0;
    vertical-align: top;
    background: #fff;
    width: 14.28%;
    overflow: hidden;
}
.calendar-day-link {
    display: block;
    width: 100%;
    height: 100%;
    padding: .5rem;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background .12s ease;
}
.calendar-day-link:hover { background: rgba(214,0,111,.06); }
.calendar-day.empty { background: transparent; border-color: transparent; }
.calendar-day.weekend { background: #f7f8fc; }
.calendar-day.today { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(214,0,111,.15); }
.calendar-date { font-weight: 700; font-size: .82rem; margin-bottom: .3rem; }
.calendar-info { font-size: .68rem; line-height: 1.35; color: var(--text-muted); }
.calendar-badge {
    display: inline-block;
    font-size: .64rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: 6px;
    color: #fff;
    margin-bottom: .25rem;
}

.sidebar .nav-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sidebar .nav-link.active {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 10px rgba(214,0,111,.4);
}

.sidebar-footer {
    padding: .8rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.logout-link { color: #fca5a5 !important; }
.logout-link:hover { background: rgba(220,38,38,.15) !important; color: #fecaca !important; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,15,25,.5);
    z-index: 1020;
}
.sidebar-overlay.show { display: block; }

/* ===================== MAIN AREA ===================== */
.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 68px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1010;
}

.sidebar-toggle {
    display: none;
    border: none;
    background: #f1f2f8;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    color: #1f2430;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fbe4f0;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 600; font-size: .88rem; }
.user-role { font-size: .74rem; color: var(--text-muted); }

.content-area {
    padding: 1.6rem;
    flex: 1;
}

.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: .8rem;
    padding: 1rem;
}

/* ===================== CARDS / COMPONENTS ===================== */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: 0 2px 14px rgba(20,20,50,0.06);
}

.page-heading {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: .25rem;
}
.page-subheading { color: var(--text-muted); margin-bottom: 1.5rem; }

.stat-card {
    border-radius: 16px;
    padding: 1.3rem 1.4rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-card h3 { font-size: 1.7rem; margin: 0; font-weight: 800; }
.stat-card .stat-label { opacity: .9; font-size: .82rem; }

.bg-blue   { background: linear-gradient(135deg, var(--secondary-dark), var(--secondary-light)); }
.bg-green  { background: linear-gradient(135deg,#0f9d58,#22c55e); }
.bg-orange { background: linear-gradient(135deg,#c2600a,#f59e0b); }
.bg-red    { background: linear-gradient(135deg,#b91c1c,#ef4444); }
.bg-purple { background: linear-gradient(135deg,#6d28d9,#8b5cf6); }
.bg-cyan   { background: linear-gradient(135deg, var(--secondary-dark), var(--secondary)); }

#map, #mapPengaturan {
    height: 420px;
    width: 100%;
    border-radius: 14px;
    z-index: 1;
    border: 1px solid var(--border);
}

.badge-status-hadir { background-color: var(--success); }
.badge-status-terlambat { background-color: var(--danger); }
.badge-status-izin { background-color: #0ea5e9; }
.badge-status-sakit { background-color: #8b5cf6; }
.badge-status-alpha { background-color: #6b7280; }

.btn {
    border-radius: 10px;
    font-weight: 600;
    font-size: .88rem;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-success { background-color: var(--success); border-color: var(--success); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background-color: var(--primary); border-color: var(--primary); }

.table thead th {
    background-color: #f4f5fb;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    border-bottom: none;
    font-weight: 700;
}
.table td, .table th { vertical-align: middle; padding: .8rem .9rem; }
.table tbody tr:hover { background-color: #f9fafc; }

.jarak-info {
    font-size: 0.92rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.jarak-info .row-item { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); }

.form-label { font-weight: 600; font-size: .85rem; color: #374151; }
.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--border);
    padding: .55rem .8rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 .2rem rgba(214,0,111,.15);
}

.status-tile {
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 1.6rem 1rem;
    text-align: center;
}
.status-tile .status-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto .75rem;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .content-area { padding: 1.1rem; }
}

@media print {
    .sidebar, .topbar, .app-footer, .no-print { display: none !important; }
    .main-area { width: 100%; }
    .content-area { padding: 0; }
}
