/* ===== Variables ===== */
:root {
    --sidebar-w: 260px;
    --sidebar-bg: #0f2044;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(59,130,246,0.25);
    --sidebar-accent: #3b82f6;
    --header-h: 64px;
    --page-bg: #eef2f7;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --chart-bg: #fdf8e1;
    --chart-bar: #00897b;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --radius: 10px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Poppins', sans-serif;
    background: var(--page-bg);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    font-size: 14px;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    text-decoration: none;
    color: #fff;
}
.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}
.brand-text .brand-title {
    display: block;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    line-height: 1.2;
}
.brand-text .brand-sub {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    margin-top: 1px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    padding: 16px 16px 6px;
}

.sidebar-nav { list-style: none; margin: 0; padding: 8px 0; }
.sidebar-nav-item { margin: 2px 8px; }
.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,0.72);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}
.sidebar-nav-link i { width: 20px; text-align: center; font-size: 14px; flex-shrink: 0; }
.sidebar-nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav-item.active .sidebar-nav-link {
    background: var(--sidebar-active);
    color: #fff;
    border-left: 3px solid var(--sidebar-accent);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.07);
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    line-height: 1.8;
}
.sidebar-footer strong { color: rgba(255,255,255,0.7); }

/* ===== Overlay (mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ===== Top Header ===== */
.top-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.08);
    flex-shrink: 0;
}
.sidebar-toggle {
    background: none;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--page-bg); color: var(--text-main); }

.header-info { flex: 1; min-width: 0; }
.header-info h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.header-info small { color: var(--text-muted); font-size: 12px; }

.header-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.badge-year {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 600;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
}

/* ===== Content Wrapper ===== */
.content-wrapper { padding: 20px; flex: 1; }

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--card-shadow);
    height: 100%;
    border-left: 4px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    color: #fff;
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-main);
}
.stat-label {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}

.stat-blue  { border-color: #3b82f6; }
.stat-blue .stat-icon  { background: linear-gradient(135deg,#3b82f6,#60a5fa); }
.stat-green { border-color: #10b981; }
.stat-green .stat-icon { background: linear-gradient(135deg,#10b981,#34d399); }
.stat-orange{ border-color: #f59e0b; }
.stat-orange .stat-icon{ background: linear-gradient(135deg,#f59e0b,#fbbf24); }
.stat-teal  { border-color: #06b6d4; }
.stat-teal .stat-icon  { background: linear-gradient(135deg,#06b6d4,#22d3ee); }

/* ===== Card ===== */
.dash-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.dash-card-header {
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.dash-card-header h5 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-main);
}
.dash-card-header small { color: var(--text-muted); font-size: 12px; }
.dash-card-body { padding: 16px 18px; }

/* ===== Progress Overall ===== */
.progress-overall {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--card-shadow);
}
.progress-overall .progress { height: 18px; border-radius: 9px; background: #e2e8f0; }
.progress-overall .progress-bar { border-radius: 9px; font-size: 11px; font-weight: 600; }
.progress-tick {
    position: relative;
    height: 14px;
    margin-top: 2px;
}
.progress-tick-mark {
    position: absolute;
    font-size: 10px;
    color: var(--text-muted);
    transform: translateX(-50%);
}

/* ===== Chart ===== */
.chart-area {
    background: var(--chart-bg);
    border-radius: 8px;
    padding: 12px 8px 8px 8px;
    min-height: 420px;
    position: relative;
}
.chart-area canvas { max-width: 100% !important; }

/* ===== Table ===== */
.table-wrapper { overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table thead th {
    background: #1e293b;
    color: #fff;
    padding: 10px 12px;
    white-space: nowrap;
    font-weight: 600;
    font-size: 12px;
}
.dash-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.15s; }
.dash-table tbody tr:hover { background: #f8fafc; }
.dash-table tbody td { padding: 9px 12px; vertical-align: middle; }
.dash-table .text-end { text-align: right; }
.dash-table .text-center { text-align: center; }

.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }

.mini-progress { display: flex; align-items: center; gap: 6px; min-width: 120px; }
.mini-progress-bar { flex: 1; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.mini-progress-fill { height: 100%; border-radius: 3px; }
.fill-success { background: #22c55e; }
.fill-warning { background: #f59e0b; }
.fill-danger  { background: #ef4444; }

code.kode { background: #f1f5f9; color: #475569; padding: 2px 6px; border-radius: 4px; font-size: 11.5px; }

/* ===== Footer ===== */
.content-footer {
    background: #fff;
    border-top: 1px solid #f1f5f9;
    padding: 12px 20px;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.sidebar-open { transform: translateX(0); }
    .sidebar-overlay { display: block; }
    .main-content { margin-left: 0 !important; }
    .content-wrapper { padding: 14px; }
    .stat-value { font-size: 18px; }
    .stat-icon { width: 42px; height: 42px; font-size: 18px; }
    .top-header { padding: 0 14px; }
    .header-info h5 { font-size: 13.5px; }
    .chart-area { min-height: 520px; }
    .dash-table { font-size: 12px; }
    .dash-table thead th, .dash-table tbody td { padding: 8px 10px; }
}

@media (max-width: 575.98px) {
    .header-info small { display: none; }
    .badge-year { display: none; }
    .stat-label { font-size: 10.5px; }
}

/* ===== Age Group Tabs ===== */
.age-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e2e8f0;
}
.age-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    background: #fff;
    color: #64748b;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .2s, background .2s, color .2s;
}
.age-tab:hover { border-color: #94a3b8; color: #374151; }
.age-tab.active { background: #1e293b; border-color: #1e293b; color: #fff; }
.age-tab-pane { display: none; }
.age-tab-pane.active { display: block; }

/* ===== Utility ===== */
.gap-3 { gap: 12px; }
.mb-4 { margin-bottom: 20px !important; }
.fw-bold { font-weight: 700; }
.text-success-600 { color: #16a34a; }
.text-warning-600 { color: #d97706; }
.text-danger-600  { color: #dc2626; }

/* ===== Sidebar Auth Button ===== */
.btn-sidebar-auth {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: #fff;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .2s, transform .15s, box-shadow .2s;
    box-shadow: 0 2px 8px rgba(59,130,246,.35);
    margin-top: 2px;
}
.btn-sidebar-auth:hover  { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(59,130,246,.45); }
.btn-sidebar-auth:active { transform: translateY(0); }

/* ===== Login Modal ===== */
.login-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}
.login-overlay.show { display: flex; }
.login-box {
    background: #fff;
    border-radius: 14px;
    width: 320px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25);
    overflow: hidden;
}
.login-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}
.login-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    padding: 0 4px;
}
.login-close:hover { color: #475569; }
.login-box form { padding: 20px; }
.login-error {
    margin: 0 20px;
    padding: 10px 14px;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 8px;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.login-field { margin-bottom: 14px; }
.login-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}
.login-field input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.login-field input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.login-submit {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity .2s;
    margin-top: 4px;
}
.login-submit:hover { opacity: .9; }

/* ===== Export PDF Button ===== */
.btn-export-pdf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s, transform .15s, box-shadow .2s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(59,130,246,.3);
}
.btn-export-pdf:hover  { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,.4); }
.btn-export-pdf:active { transform: translateY(0); opacity: 1; }

/* ===== Print / Export PDF ===== */
@media print {
    /* Sembunyikan elemen UI */
    .sidebar,
    .sidebar-overlay,
    .sidebar-toggle,
    .btn-export-pdf,
    .content-footer     { display: none !important; }

    /* Hilangkan margin sidebar */
    .main-content       { margin-left: 0 !important; }

    /* Header tidak sticky saat cetak */
    .top-header {
        position: static !important;
        box-shadow: none !important;
        border-bottom: 1px solid #ddd;
        padding: 8px 16px !important;
    }

    .content-wrapper    { padding: 12px !important; }

    /* Latar putih */
    body, .dash-card, .stat-card, .progress-overall {
        background: #fff !important;
        box-shadow: none !important;
    }

    /* Hindari potong di tengah kartu */
    .dash-card, .stat-card { break-inside: avoid; page-break-inside: avoid; }

    /* Tambah jeda halaman antar section besar */
    #sec-chart-pendaftar,
    #sec-chart-capaian,
    #sec-chart-usia,
    #sec-table           { page-break-before: auto; }

    /* Grafik tetap terlihat */
    .chart-area          { background: #fff !important; min-height: 300px !important; }

    /* Pastikan semua pane usia tampil */
    .age-tab-pane        { display: block !important; }
}
