/* =====================================================================
   Back Office - theme
   Light/dark lewat atribut data-bs-theme pada <html> (lihat toggle di topbar).
   ===================================================================== */
:root {
    --bo-primary: #4f46e5;
    --bo-primary-dark: #4338ca;
    --bo-primary-soft: #eef2ff;
    --bo-bg: #f5f7fb;
    --bo-surface: #ffffff;
    --bo-surface-2: #f8fafc;
    --bo-border: #e6e9f0;
    --bo-text: #1e293b;
    --bo-muted: #64748b;
    --bo-success: #16a34a;
    --bo-danger: #dc2626;
    --bo-warning: #f59e0b;
    --bo-sidebar-width: 256px;
    --bo-sidebar-bg: #0f172a;
    --bo-sidebar-text: #94a3b8;
    --bo-sidebar-hover: #1e293b;
    --bo-radius: .75rem;
    --bo-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
}

[data-bs-theme="dark"] {
    --bo-primary-soft: rgba(99, 102, 241, .16);
    --bo-bg: #0b1220;
    --bo-surface: #111a2e;
    --bo-surface-2: #16213a;
    --bo-border: #22304d;
    --bo-text: #e2e8f0;
    --bo-muted: #94a3b8;
    --bo-sidebar-bg: #0a0f1d;
    --bo-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --bs-body-bg: var(--bo-bg);
    --bs-body-color: var(--bo-text);
    --bs-border-color: var(--bo-border);
}

* { box-sizing: border-box; }

body {
    background-color: var(--bo-bg);
    color: var(--bo-text);
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: .9rem;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ---------- LAYOUT ---------- */
.wrapper { display: flex; min-height: 100vh; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content-body { padding: 1.5rem; max-width: 1600px; width: 100%; margin: 0 auto; }

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: var(--bo-sidebar-width);
    flex-shrink: 0;
    background-color: var(--bo-sidebar-bg);
    min-height: 100vh;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    transition: margin-left .2s ease;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
.sidebar.collapsed { margin-left: calc(var(--bo-sidebar-width) * -1); }

.sidebar-brand {
    padding: 1.15rem 1.35rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .7rem;
    letter-spacing: .01em;
}
.sidebar-brand i {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bo-primary);
    border-radius: .6rem;
    font-size: .95rem;
}

.sidebar-nav { padding: .25rem .75rem 2rem; }
.sidebar-nav .nav-item { margin-bottom: 2px; }

.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: 0;
    padding: .9rem .6rem .35rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    font-weight: 700;
}
.nav-group-toggle:hover { color: #cbd5e1; }
.nav-group-toggle .chev { font-size: .6rem; transition: transform .2s; }
.nav-group-toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }

.sidebar .nav-link {
    color: var(--bo-sidebar-text);
    padding: .55rem .8rem;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-radius: .55rem;
    transition: background .15s, color .15s;
}
.sidebar .nav-link i { width: 18px; text-align: center; font-size: .9rem; opacity: .85; }
.sidebar .nav-link:hover { background-color: var(--bo-sidebar-hover); color: #fff; }
.sidebar .nav-link.active {
    background-color: var(--bo-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .35);
}
.sidebar .nav-link.active i { opacity: 1; }

/* ---------- TOPBAR ---------- */
.topbar {
    background-color: var(--bo-surface);
    border-bottom: 1px solid var(--bo-border);
    padding: .6rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.sidebar-toggle, .icon-btn {
    color: var(--bo-muted);
    border: 0;
    background: none;
    width: 38px; height: 38px;
    border-radius: .6rem;
    display: inline-flex; align-items: center; justify-content: center;
    position: relative;
}
.sidebar-toggle:hover, .icon-btn:hover { background: var(--bo-surface-2); color: var(--bo-text); }
.icon-btn .badge-dot {
    position: absolute; top: 4px; right: 3px;
    min-width: 17px; height: 17px; padding: 0 4px;
    background: var(--bo-danger); color: #fff;
    border-radius: 999px; font-size: .62rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.notif-menu { width: 340px; max-height: 420px; overflow-y: auto; padding: 0; }
.notif-item { display: flex; gap: .7rem; padding: .7rem 1rem; border-bottom: 1px solid var(--bo-border); color: var(--bo-text); }
.notif-item:hover { background: var(--bo-surface-2); color: var(--bo-text); }
.notif-item .n-icon { width: 34px; height: 34px; border-radius: .6rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.user-dropdown-toggle { color: var(--bo-text); }
.avatar-circle {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bo-primary), #7c3aed);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}

/* ---------- PAGE HEADER ---------- */
.page-header { margin-bottom: 1.25rem; }
.page-title { font-weight: 700; font-size: 1.35rem; letter-spacing: -.01em; }
.breadcrumb { font-size: .8rem; }

/* ---------- CARD ---------- */
.card {
    border: 1px solid var(--bo-border);
    border-radius: var(--bo-radius);
    background-color: var(--bo-surface);
    box-shadow: var(--bo-shadow);
}

/* Section header: header kartu yang bersih (bukan lagi blok biru penuh) */
.section-header {
    background: transparent;
    color: var(--bo-text);
    padding: .95rem 1.25rem;
    border-bottom: 1px solid var(--bo-border);
    border-radius: var(--bo-radius) var(--bo-radius) 0 0;
    font-weight: 600;
    font-size: .92rem;
}
.section-header > i:first-child, .section-header span > i:first-child { color: var(--bo-primary); }
.card > .card-header { background: transparent; border-bottom: 1px solid var(--bo-border); }
.card > .card-header.bg-primary { background: var(--bo-primary) !important; }

.kpi-card {
    border: 1px solid var(--bo-border);
    border-radius: var(--bo-radius);
    background: var(--bo-surface);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--bo-shadow);
    height: 100%;
}
.kpi-card .kpi-icon {
    width: 44px; height: 44px;
    border-radius: .7rem;
    display: flex; align-items: center; justify-content: center;
    background-color: var(--bo-primary-soft);
    color: var(--bo-primary);
    font-size: 1.1rem;
    flex-shrink: 0;
}
.kpi-card .kpi-value { font-size: clamp(1.1rem, 1.5vw, 1.45rem); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.kpi-card .d-flex > div:last-child { min-width: 0; }
.kpi-card .kpi-label { font-size: .78rem; color: var(--bo-muted); }

/* ---------- BUTTON / FORM ---------- */
.btn { border-radius: .55rem; font-weight: 500; }
.btn-primary { background-color: var(--bo-primary); border-color: var(--bo-primary); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--bo-primary-dark); border-color: var(--bo-primary-dark); }
.btn-outline-primary { color: var(--bo-primary); border-color: var(--bo-primary); }
.btn-outline-primary:hover { background-color: var(--bo-primary); border-color: var(--bo-primary); }
.form-control, .form-select { border-radius: .55rem; border-color: var(--bo-border); background-color: var(--bo-surface); color: var(--bo-text); }
.form-control:focus, .form-select:focus { border-color: var(--bo-primary); box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15); }
/* Focus ring seragam untuk navigasi keyboard (PRD T6 a11y / AC-6). */
.btn:focus-visible, .nav-link:focus-visible, .page-link:focus-visible,
.dropdown-item:focus-visible, .nav-group-toggle:focus-visible,
.form-check-input:focus-visible {
    outline: 2px solid var(--bo-primary);
    outline-offset: 2px;
}
.form-label { font-weight: 500; font-size: .82rem; color: var(--bo-muted); margin-bottom: .3rem; }

/* ---------- TABLE ---------- */
.table { --bs-table-bg: transparent; color: var(--bo-text); }
.table thead th {
    background-color: var(--bo-surface-2);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bo-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--bo-border);
    white-space: nowrap;
}
.table td, .table th { vertical-align: middle; font-size: .865rem; border-color: var(--bo-border); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--bo-surface-2); }

.badge { font-weight: 600; letter-spacing: .01em; border-radius: .45rem; }
.badge.bg-light { background-color: var(--bo-surface-2) !important; color: var(--bo-text) !important; border-color: var(--bo-border) !important; }

.profit-positive { color: var(--bo-success); font-weight: 600; }
.profit-negative { color: var(--bo-danger); font-weight: 600; }

/* ---------- PAGINATION KEBUNI ---------- */
/* Dipakai oleh template app/Views/pager/kebuni_full.php + partials/pager_footer.php.
   Aksen memakai token --bo-primary (indigo) sesuai OQ-1 PRD-BACKOFFICE-UI. */
.pagination { gap: .25rem; }
.pagination .page-link {
    border: 1px solid var(--bo-border);
    border-radius: .5rem;
    min-width: 2.375rem;
    text-align: center;
    color: var(--bo-text);
    background-color: var(--bo-surface);
    font-variant-numeric: tabular-nums;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.pagination .page-link:hover {
    background-color: var(--bo-surface-2);
    color: var(--bo-primary);
    border-color: var(--bo-primary);
}
.pagination .page-link:focus { box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15); }
.pagination .page-item.active .page-link {
    background-color: var(--bo-primary);
    border-color: var(--bo-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(79, 70, 229, .35);
}
.pagination .page-item.disabled .page-link { opacity: .45; }
/* Info baris: "Menampilkan 1–10 dari 57 data" */
.pager-info { font-size: .83rem; color: var(--bo-muted); font-variant-numeric: tabular-nums; }
/* Angka tabular agar kolom angka tidak "melompat" saat halaman berganti */
.num { font-variant-numeric: tabular-nums; }

/* ---------- TABLE SKELETON (loading baris tabel, pengganti overlay global) ---------- */
.skel-bar {
    height: .85rem;
    border-radius: .35rem;
    background: linear-gradient(90deg, var(--bo-surface-2) 25%, var(--bo-border) 50%, var(--bo-surface-2) 75%);
    background-size: 200% 100%;
    animation: skel-shimmer 1.2s infinite linear;
}
@keyframes skel-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel-bar { animation: none; } }

/* ---------- EMPTY STATE ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--bo-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: .75rem; color: var(--bo-border); }

/* ---------- MODAL / DROPDOWN ---------- */
.modal-content, .dropdown-menu { border-radius: var(--bo-radius); border-color: var(--bo-border); background-color: var(--bo-surface); box-shadow: var(--bo-shadow); }
.dropdown-item { color: var(--bo-text); }
.dropdown-item:hover { background: var(--bo-surface-2); color: var(--bo-text); }

/* ---------- LOADING OVERLAY ---------- */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .25);
    backdrop-filter: blur(1px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1090;
}
.loading-overlay.d-none { display: none !important; }

/* ---------- AUTH PAGES ---------- */
.auth-body { background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #ecfeff 100%); }
[data-bs-theme="dark"] .auth-body { background: linear-gradient(135deg, #0b1220, #111a2e); }
.auth-card { width: 100%; max-width: 420px; border-radius: 1rem; }

/* ---------- ABSENSI (PUBLIC) ---------- */
.attendance-wrapper { max-width: 460px; margin: 0 auto; padding: 1.25rem; }
#cameraPreview, #photoPreview { width: 100%; border-radius: var(--bo-radius); background: #000; }

/* ---------- RESPONSIVE ---------- */
/* Di layar lebar tombol tutup & backdrop disembunyikan (harus SEBELUM media query
   agar rule mobile di bawah bisa menimpanya). */
.sidebar-backdrop, .sidebar-close { display: none; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 1050; margin-left: calc(var(--bo-sidebar-width) * -1); }
    .sidebar.show { margin-left: 0; box-shadow: 0 0 24px rgba(15, 23, 42, .45); }
    .sidebar-close {
        margin-left: auto;
        width: 34px; height: 34px;
        display: inline-flex; align-items: center; justify-content: center;
        border: 0; border-radius: .5rem;
        background: rgba(255, 255, 255, .08);
        color: var(--bo-sidebar-text);
        font-size: 1.1rem;
    }
    .sidebar-close:hover { background: var(--bo-sidebar-hover); color: #fff; }
    .sidebar-backdrop {
        position: fixed; inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 1040;
    }
    .sidebar-backdrop.show { display: block; }
    .content-body { padding: 1rem; }
}

/* ---------- PRINT ---------- */
@media print {
    .sidebar, .topbar, .no-print, .page-header .breadcrumb { display: none !important; }
    .main-content { margin: 0 !important; }
    .content-body { padding: 0 !important; max-width: none; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border-color: #ddd; }
}
