/* ===== Color Variables ===== */
:root {
    --sidebar-bg: #0f172a;
    --sidebar-width: 250px;
    --primary: #3b82f6;
    --primary-dark: #1d4ed8;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-muted-sidebar: #94a3b8;
    --sidebar-hover: rgba(59,130,246,0.15);
    --sidebar-active: rgba(59,130,246,0.25);
    --content-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--content-bg);
    margin: 0;
    padding: 0;
    color: #1e293b;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0,0,0,.25);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .brand-logo {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff; 
    margin: 0 auto 10px;
    box-shadow: 0 4px 12px rgba(59,130,246,.4);
}
.sidebar-brand h5 {
    color: #fff; font-size: 0.95rem; font-weight: 700;
    margin: 0; letter-spacing: .3px;
}
.sidebar-brand small {
    color: var(--text-muted-sidebar); font-size: 0.72rem; font-weight: 400;
}
.role-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(59,130,246,.2); color: var(--primary);
    border-radius: 20px; padding: 2px 10px; font-size: 0.7rem;
    font-weight: 600; margin-top: 4px; letter-spacing: .4px;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-label {
    padding: 12px 20px 5px;
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.2px;
    color: #475569;
}

.sidebar a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px;
    color: var(--text-muted-sidebar);
    text-decoration: none;
    font-size: 0.83rem; font-weight: 500;
    border-radius: 0;
    transition: all .18s ease;
    border-left: 3px solid transparent;
}
.sidebar a:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
    border-left-color: rgba(59,130,246,.5);
}
.sidebar a.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar a .nav-icon {
    width: 28px; height: 28px;
    background: rgba(255,255,255,.06);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.78rem;
    color: var(--text-muted-sidebar);
    transition: all .18s ease;
}
.sidebar a:hover .nav-icon {
    background: rgba(255,255,255,.12);
    color: #e2e8f0;
}
.sidebar a.active .nav-icon {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 10px rgba(59,130,246,.35);
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-footer a {
    color: #ef4444 !important;
}
.sidebar-footer a:hover {
    background: rgba(239,68,68,.12) !important;
    border-left-color: #ef4444 !important;
}

/* ===== MAIN CONTENT ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 28px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.topbar .page-title {
    font-size: 0.88rem; font-weight: 500; color: #64748b; margin: 0;
}
.topbar .page-title span { color: #1e293b; font-weight: 600; }
.topbar-right {
    display: flex; align-items: center; gap: 14px;
}
.topbar-user {
    display: flex; align-items: center; gap: 9px;
}
.topbar-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.8rem; font-weight: 700;
}
.topbar-user-info small { display: block; font-size: 0.72rem; color: #94a3b8; }
.topbar-user-info strong { font-size: 0.82rem; color: #1e293b; }

.content-body {
    padding: 24px 28px;
}

/* ===== CARDS ===== */
.card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}
.card-header {
    border-radius: 12px 12px 0 0 !important;
    padding: 14px 20px;
    font-size: 0.88rem;
    border-bottom: 1px solid rgba(0,0,0,.06);
}

/* ===== ALERTS ===== */
.alert {
    border-radius: 10px;
    border: none;
    font-size: 0.875rem;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ===== TABLES ===== */
.table { font-size: 0.855rem; }
.table thead th {
    font-weight: 600; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: .5px;
}

/* ===== BUTTONS ===== */
.btn { font-size: 0.84rem; font-weight: 500; border-radius: 8px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ===== BADGES ===== */
.badge { font-weight: 500; border-radius: 6px; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px;
}
.page-header h2 {
    font-size: 1.4rem; font-weight: 700; color: #0f172a; margin: 0;
}
.page-header h2 i { color: var(--primary); margin-right: 10px; }

/* ===== PAGINATION ===== */
.pagination { gap: 2px; }
.pagination .page-link { border-radius: 6px; font-size: 0.82rem; padding: 4px 12px; }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ===== PROGRESS BARS ===== */
.progress { height: 8px; border-radius: 4px; background-color: #e2e8f0; }

/* ===== STAT CARDS ===== */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    border-left: 4px solid var(--primary);
    box-shadow: var(--card-shadow);
}
.stat-card .stat-value { font-size: 1.3rem; font-weight: 700; color: inherit; }
.stat-card .stat-label { font-size: 0.78rem; color: inherit; opacity: 0.85; margin-top: 2px; }
.stat-card .stat-sub { font-size: 0.78rem; color: inherit; opacity: 0.75; }

/* ===== MOBILE RESPONSIVE ===== */
.mobile-toggle { display: none; background: none; border: none; font-size: 1.3rem; color: #1e293b; cursor: pointer; padding: 0; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.6); z-index: 90; backdrop-filter: blur(2px); }
@media (max-width: 768px) {
    .mobile-toggle { display: block; }
    .sidebar { transform: translateX(-100%); transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: none; }
    .sidebar.show { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.4); }
    .sidebar-overlay.show { display: block; }
    .main-wrapper { margin-left: 0; }
    .topbar { padding: 12px 20px; }
    .content-body { padding: 20px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* ===== MEMBER SEARCH SUGGESTIONS ===== */
.member-search-wrap .input-group { border: 1.5px solid #e2e8f0; border-radius: 8px; overflow: hidden; transition: border-color .2s; }
.member-search-wrap .input-group:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.member-search-wrap .input-group-text, .member-search-wrap .form-control { border: none; background: #fff; }
.member-suggestions {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 999;
    background: #fff; border-radius: 8px; border: 1px solid #e2e8f0;
    max-height: 220px; overflow-y: auto; display: none;
}
.member-suggestions .sugg-item {
    padding: 8px 14px; cursor: pointer; font-size: 0.84rem;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid #f1f5f9; transition: background .15s;
}
.member-suggestions .sugg-item:last-child { border-bottom: none; }
.member-suggestions .sugg-item:hover, .member-suggestions .sugg-item.active { background: #eff6ff; }
.member-suggestions .sugg-item .sugg-badge { font-size: 0.72rem; background: #dbeafe; color: #1d4ed8; border-radius: 5px; padding: 1px 7px; font-weight: 600; white-space: nowrap; }
.member-suggestions .sugg-item .sugg-name { font-weight: 500; color: #1e293b; }
.member-suggestions .sugg-empty { padding: 12px 14px; font-size: 0.83rem; color: #94a3b8; text-align: center; }

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    background: none; border: 1px solid #e2e8f0; color: #64748b;
    border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1rem; transition: all .2s;
}
.theme-toggle:hover { background: #f1f5f9; color: #1e293b; }

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --content-bg: #0f172a;
    --card-shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.4);
    --sidebar-hover: rgba(59,130,246,.1);
    --sidebar-active: rgba(59,130,246,.2);
    color-scheme: dark;
}

[data-theme="dark"] body {
    background-color: var(--content-bg);
    color: #e2e8f0;
}

[data-theme="dark"] .topbar {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
[data-theme="dark"] .topbar .page-title { color: #94a3b8; }
[data-theme="dark"] .topbar .page-title span { color: #e2e8f0; }
[data-theme="dark"] .topbar-user-info strong { color: #e2e8f0; }
[data-theme="dark"] .topbar-avatar { color: #fff; }
[data-theme="dark"] .mobile-toggle { color: #e2e8f0; }

[data-theme="dark"] .card {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .card-header {
    border-color: rgba(255,255,255,.06);
}
[data-theme="dark"] .card-header.bg-white { background: #1e293b !important; }

[data-theme="dark"] .table { color: #e2e8f0; }
[data-theme="dark"] .table thead th { color: #94a3b8; }
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) { background: rgba(255,255,255,.02); --bs-table-accent-bg: rgba(255,255,255,.02); }
[data-theme="dark"] .table-hover > tbody > tr:hover { background: rgba(255,255,255,.04); }
[data-theme="dark"] .table-bordered { border-color: #334155; }
[data-theme="dark"] .table-bordered > :not(caption) > * { border-color: #334155; }

[data-theme="dark"] .form-control, [data-theme="dark"] .form-select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .form-control:focus, [data-theme="dark"] .form-select:focus {
    background: #0f172a;
    border-color: #3b82f6;
    color: #e2e8f0;
}
[data-theme="dark"] .input-group-text {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .dropdown-menu {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .dropdown-item { color: #e2e8f0; }
[data-theme="dark"] .dropdown-item:hover { background: rgba(255,255,255,.05); color: #fff; }
[data-theme="dark"] .dropdown-divider { border-color: #334155; }
[data-theme="dark"] .dropdown-menu .fw-600 { color: #e2e8f0 !important; }

[data-theme="dark"] .stat-card {
    background: #1e293b;
}
[data-theme="dark"] .stat-card .stat-value { color: #e2e8f0; }
[data-theme="dark"] .stat-card .stat-label { color: #94a3b8; }

[data-theme="dark"] .page-header h2 { color: #f1f5f9; }

[data-theme="dark"] .alert-success { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .alert-danger { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fde68a; }
[data-theme="dark"] .alert-info { background: #0c4a6e; color: #bae6fd; }

[data-theme="dark"] .btn-outline-secondary {
    color: #94a3b8;
    border-color: #475569;
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .btn-light {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}
[data-theme="dark"] .btn-light:hover {
    background: #475569;
}

[data-theme="dark"] .badge.bg-light { background: #334155 !important; color: #e2e8f0 !important; }
[data-theme="dark"] .text-dark { color: #e2e8f0 !important; }
[data-theme="dark"] .text-muted { color: #94a3b8 !important; }
[data-theme="dark"] .border { border-color: #334155 !important; }
[data-theme="dark"] .border-bottom { border-color: #334155 !important; }
[data-theme="dark"] hr { border-color: #334155; }

[data-theme="dark"] .modal-content {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .modal-header {
    border-color: #334155;
}
[data-theme="dark"] .modal-footer {
    border-color: #334155;
}
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] .pagination .page-link {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
[data-theme="dark"] .pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

[data-theme="dark"] .member-search-wrap .input-group { border-color: #334155; }
[data-theme="dark"] .member-search-wrap .input-group-text,
[data-theme="dark"] .member-search-wrap .form-control {
    background: #0f172a;
}
[data-theme="dark"] .member-suggestions {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .member-suggestions .sugg-item { border-color: #334155; }
[data-theme="dark"] .member-suggestions .sugg-item:hover,
[data-theme="dark"] .member-suggestions .sugg-item.active { background: rgba(59,130,246,.15); }
[data-theme="dark"] .member-suggestions .sugg-item .sugg-name { color: #e2e8f0; }

[data-theme="dark"] .theme-toggle {
    border-color: #475569;
    color: #94a3b8;
}
[data-theme="dark"] .theme-toggle:hover { background: #334155; color: #e2e8f0; }

[data-theme="dark"] .progress { background-color: #334155; }

.table td.text-end,
.table td[style*="text-align:right"],
.stat-card .stat-value,
.kw-info-item span,
td:has(.amount),
td:has(.jumlah) {
    white-space: nowrap;
}

[data-theme="dark"] .card-header.bg-white h5,
[data-theme="dark"] .card-header.bg-white h6 { color: #e2e8f0; }
[data-theme="dark"] .form-label { color: #cbd5e1; }
[data-theme="dark"] .text-muted { color: #94a3b8 !important; }
[data-theme="dark"] .alert-success { background: #064e3b; color: #a7f3d0; border-color: #065f46; }
[data-theme="dark"] .alert-danger { background: #7f1d1d; color: #fecaca; border-color: #991b1b; }
