/* =====================================================================
   SIPESAT - Custom Style (tema hijau lingkungan)
   ===================================================================== */
:root {
    --sp-green: #198754;
    --sp-green-dark: #0f5132;
    --sp-green-darker: #0a3622;
    --sp-green-light: #d1e7dd;
    --sp-sidebar-w: 260px;
    --sp-topbar-h: 60px;
}

body {
    background: #f3f6f4;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: .925rem;
    color: #212529;
}

/* ---------- Layout ---------- */
.app-wrapper { min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sp-sidebar-w);
    background: linear-gradient(180deg, var(--sp-green-dark) 0%, var(--sp-green-darker) 100%);
    color: #fff;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    min-height: var(--sp-topbar-h);
}
.brand-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: rgba(255,255,255,.15);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.brand-sub { font-size: .7rem; opacity: .75; }

.sidebar-user {
    display: flex; align-items: center;
    padding: 14px 18px;
    background: rgba(0,0,0,.15);
    font-size: .85rem;
}
.sidebar-user .avatar {
    width: 38px; height: 38px; flex-shrink: 0;
    border-radius: 50%;
    background: #fff; color: var(--sp-green);
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

.sidebar-nav { padding: 10px 10px 30px; }
.sidebar-nav .nav-heading {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    opacity: .55; padding: 14px 12px 4px;
}
.sidebar-nav .nav-link {
    color: rgba(255,255,255,.85);
    border-radius: 8px;
    padding: 9px 12px;
    display: flex; align-items: center; gap: 10px;
    font-size: .9rem;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav .nav-link.active { background: #fff; color: var(--sp-green-dark); font-weight: 600; }
.sidebar-nav .chevron { font-size: .75rem; transition: transform .2s; }
.sidebar-nav .nav-link.collapsed .chevron { transform: rotate(-90deg); }
.sidebar-nav .submenu { list-style: none; padding-left: 14px; margin: 2px 0 4px; }
.sidebar-nav .submenu .nav-link { font-size: .85rem; padding: 7px 12px; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1035;
}

.main-content {
    margin-left: var(--sp-sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left .25s ease;
}
.topbar {
    position: sticky; top: 0; z-index: 1020;
    height: var(--sp-topbar-h);
    background: #fff;
    border-bottom: 1px solid #e3e8e5;
    display: flex; align-items: center;
    padding: 0 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--sp-green-dark); }
.content-body { padding: 22px; flex: 1; }
.app-footer {
    padding: 14px 22px; font-size: .8rem; color: #6c757d;
    border-top: 1px solid #e3e8e5; background: #fff;
}

/* Sidebar tertutup (desktop) */
.app-wrapper.sidebar-collapsed .sidebar { transform: translateX(-100%); }
.app-wrapper.sidebar-collapsed .main-content { margin-left: 0; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .app-wrapper.sidebar-open .sidebar { transform: translateX(0); }
    .app-wrapper.sidebar-open .sidebar-backdrop { display: block; }
    .content-body { padding: 14px; }
}

/* ---------- Cards ---------- */
.card { border: none; border-radius: 12px; box-shadow: 0 2px 10px rgba(16, 80, 50, .06); }
.card-header {
    background: #fff; border-bottom: 1px solid #edf1ee;
    font-weight: 600; color: var(--sp-green-dark);
    border-radius: 12px 12px 0 0 !important;
    padding: 12px 18px;
}
.card-header.bg-success { color: #fff; }

.kpi-card {
    position: relative; overflow: hidden;
    border-radius: 12px; padding: 16px 18px;
    background: #fff;
    border-left: 5px solid var(--sp-green);
    box-shadow: 0 2px 10px rgba(16, 80, 50, .07);
    height: 100%;
    transition: transform .15s, box-shadow .15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16, 80, 50, .12); }
.kpi-card .kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: #6c757d; font-weight: 600; }
.kpi-card .kpi-value { font-size: 1.35rem; font-weight: 700; color: #1d2b23; margin-top: 4px; word-break: break-word; }
.kpi-card .kpi-unit { font-size: .8rem; font-weight: 500; color: #6c757d; }
.kpi-card .kpi-icon {
    position: absolute; right: 12px; top: 12px;
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    background: var(--sp-green-light); color: var(--sp-green);
}
.kpi-card.kpi-primary { border-left-color: #0d6efd; } .kpi-card.kpi-primary .kpi-icon { background: #cfe2ff; color: #0d6efd; }
.kpi-card.kpi-warning { border-left-color: #ffc107; } .kpi-card.kpi-warning .kpi-icon { background: #fff3cd; color: #997404; }
.kpi-card.kpi-danger  { border-left-color: #dc3545; } .kpi-card.kpi-danger  .kpi-icon { background: #f8d7da; color: #dc3545; }
.kpi-card.kpi-info    { border-left-color: #0dcaf0; } .kpi-card.kpi-info    .kpi-icon { background: #cff4fc; color: #087990; }
.kpi-card.kpi-teal    { border-left-color: #20c997; } .kpi-card.kpi-teal    .kpi-icon { background: #d2f4ea; color: #13795b; }
.kpi-card.kpi-brown   { border-left-color: #8b5a2b; } .kpi-card.kpi-brown   .kpi-icon { background: #efe2d3; color: #8b5a2b; }
.kpi-card.kpi-gray    { border-left-color: #6c757d; } .kpi-card.kpi-gray    .kpi-icon { background: #e2e3e5; color: #495057; }
.kpi-card.kpi-gold    { border-left-color: #d4a017; } .kpi-card.kpi-gold    .kpi-icon { background: #fbefc9; color: #8a6a00; }

.chart-box { position: relative; height: 300px; }

/* ---------- Forms & tables ---------- */
.form-label { font-weight: 600; font-size: .85rem; color: #344038; }
.form-control:focus, .form-select:focus { border-color: #75b798; box-shadow: 0 0 0 .2rem rgba(25,135,84,.2); }
.input-group-text { background: #f1f5f2; }
.required::after { content: " *"; color: #dc3545; }

.table thead th {
    background: #e9f3ee; color: var(--sp-green-darker);
    font-size: .8rem; text-transform: uppercase; letter-spacing: .02em;
    white-space: nowrap; vertical-align: middle;
}
.table tfoot th { background: #f6faf8; }
.table td { vertical-align: middle; }
table.dataTable { margin-top: 8px !important; }
.dt-buttons .btn { margin-right: 4px; }

.btn-success { background: var(--sp-green); border-color: var(--sp-green); }
.btn-action { padding: .2rem .45rem; font-size: .8rem; }

.page-header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.page-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--sp-green-dark); margin: 0; }

.ratio-bar { height: 8px; border-radius: 4px; background: #e9ecef; overflow: hidden; }
.ratio-bar > div { height: 100%; background: var(--sp-green); transition: width .3s; }

/* Matrix absensi */
.matrix-table th, .matrix-table td { text-align: center; padding: 4px 6px !important; font-size: .78rem; }
.matrix-table td.name, .matrix-table th.name { text-align: left; white-space: nowrap; position: sticky; left: 0; background: #fff; z-index: 1; }
.matrix-table th.sunday { background: #fde2e1 !important; color: #b02a37; }
.st-badge { display: inline-block; min-width: 22px; padding: 2px 4px; border-radius: 4px; font-weight: 700; color: #fff; }
.st-hadir { background: #198754; } .st-sakit { background: #ffc107; color: #222; } .st-ijin { background: #0dcaf0; color: #222; }
.st-alpha { background: #dc3545; } .st-cuti { background: #0d6efd; } .st-minggu_off { background: #6c757d; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f5132 0%, #198754 55%, #20c997 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-card { width: 100%; max-width: 420px; border-radius: 16px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .login-head { background: #fff; text-align: center; padding: 30px 30px 10px; }
.login-card .login-logo {
    width: 74px; height: 74px; border-radius: 18px; margin: 0 auto 12px;
    background: var(--sp-green-light); color: var(--sp-green);
    display: flex; align-items: center; justify-content: center; font-size: 2.4rem;
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .app-footer, .no-print, .dt-buttons, .dataTables_filter, .dataTables_length, .dataTables_paginate, .dataTables_info { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-body { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    body { background: #fff; }
    .print-only { display: block !important; }
}
.print-only { display: none; }

/* Tombol ekspor DataTables (override btn-secondary bawaan) */
.dt-buttons .btn.btn-outline-success { background: #fff; color: #198754; border-color: #198754; }
.dt-buttons .btn.btn-outline-success:hover { background: #198754; color: #fff; }
.dt-buttons .btn.btn-outline-secondary { background: #fff; color: #495057; border-color: #6c757d; }
.dt-buttons .btn.btn-outline-secondary:hover { background: #6c757d; color: #fff; }
