/* ─── VARIABEL TEMA ─── */
:root {
    --bg-body: #0b0e14;
    --bg-sidebar: #111a24;
    --bg-card: #131c26;
    --bg-table: #111a24;
    --bg-table-header: #0d151e;
    --text-primary: #e8edf5;
    --text-secondary: #b9c7dc;
    --text-muted: #5f7390;
    --border-color: #1f2a36;
    --border-light: #2d3f52;
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
}
body.light-mode {
    --bg-body: #f0f4fa;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-table: #ffffff;
    --bg-table-header: #e9ecef;
    --text-primary: #1e293b;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}
/* ─── GLOBAL ─── */
* { box-sizing: border-box; }
html, body {
    height: 100%;
    margin: 0;
    background: var(--bg-body);
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
/* ─── SIDEBAR ─── */
.sidebar {
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    border-right: 1px solid var(--border-color);
    transition: flex 0.3s ease, max-width 0.3s ease, background 0.3s, border-color 0.3s;
}
.sidebar .brand {
    font-size: 20px; font-weight: 700;
    color: var(--text-primary);
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-color);
}
.sidebar .brand i { color: #3b82f6; margin-right: 8px; }
.sidebar .menu-item {
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    display: block;
    font-size: 14px;
    cursor: pointer;
    transition: 0.15s;
}
.sidebar .menu-item i {
    width: 24px;
    color: #6b8cff;
    display: inline-block;
    text-align: center;
    margin-right: 8px;
}
.sidebar .menu-item.active {
    background: var(--border-color);
    color: var(--text-primary);
}
.sidebar .menu-item.active i { color: #3b82f6; }
.sidebar .menu-item:not(.active):hover {
    background: var(--border-light);
    color: var(--text-primary);
}
.sidebar .menu-label {
    padding: 12px 20px 4px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}
.sidebar .logout {
    padding: 12px 20px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-top: 20px;
}
.sidebar .logout i { color: #ef4444; margin-right: 8px; }
.sidebar .theme-toggle {
    padding: 12px 20px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar .theme-toggle i { font-size: 18px; }
.sidebar .theme-toggle:hover { color: var(--text-primary); }

.main-content {
    padding: 20px 30px;
    background: var(--bg-body);
    transition: background 0.3s;
    min-height: 100vh;
}

/* ─── SIDEBAR TOGGLE ─── */
.sidebar-toggle {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 24px;
    color: var(--text-secondary);
    transition: 0.15s;
    display: block;
}
.sidebar-toggle:hover { color: var(--text-primary); }

/* ─── SIDEBAR COLLAPSE – HANYA ICON, TOMBOL TETAP ADA ─── */
.sidebar-collapsed .sidebar {
    flex: 0 0 60px !important;
    max-width: 60px !important;
    min-width: 60px !important;
    overflow: hidden !important;
}

/* Semua teks disembunyikan dengan font-size:0 */
.sidebar-collapsed .sidebar .brand,
.sidebar-collapsed .sidebar .menu-label,
.sidebar-collapsed .sidebar .menu-item,
.sidebar-collapsed .sidebar .theme-toggle,
.sidebar-collapsed .sidebar .logout,
.sidebar-collapsed .sidebar .sidebar-toggle,
.sidebar-collapsed .sidebar form,
.sidebar-collapsed .sidebar select,
.sidebar-collapsed .sidebar input,
.sidebar-collapsed .sidebar label,
.sidebar-collapsed .sidebar .form-control,
.sidebar-collapsed .sidebar .form-control-custom,
.sidebar-collapsed .sidebar .px-3,
.sidebar-collapsed .sidebar .d-flex,
.sidebar-collapsed .sidebar .gap-2,
.sidebar-collapsed .sidebar .align-items-center {
    font-size: 0 !important;
    display: block !important; /* biar tetap di flow */
}

/* Tapi ikon-ikon tetap kebesaran */
.sidebar-collapsed .sidebar .brand i,
.sidebar-collapsed .sidebar .menu-item i,
.sidebar-collapsed .sidebar .theme-toggle i,
.sidebar-collapsed .sidebar .sidebar-toggle i {
    font-size: 22px !important;
    margin-right: 0 !important;
    display: inline-block !important;
}

/* Menu item di-center dan padding diatur */
.sidebar-collapsed .sidebar .menu-item {
    padding: 12px 0 !important;
    text-align: center !important;
}
.sidebar-collapsed .sidebar .brand {
    padding: 12px 0 !important;
    text-align: center !important;
    border-bottom: none;
}
.sidebar-collapsed .sidebar .theme-toggle {
    padding: 12px 0 !important;
    justify-content: center !important;
}
.sidebar-collapsed .sidebar .logout {
    padding: 12px 0 !important;
    text-align: center !important;
}
.sidebar-collapsed .sidebar .sidebar-toggle {
    padding: 10px 0 !important;
    text-align: center !important;
}
.sidebar-collapsed .sidebar .sidebar-toggle i {
    font-size: 28px !important;
}

/* Sembunyikan form dan select secara eksplisit */
.sidebar-collapsed .sidebar form,
.sidebar-collapsed .sidebar select,
.sidebar-collapsed .sidebar input,
.sidebar-collapsed .sidebar label,
.sidebar-collapsed .sidebar .form-control,
.sidebar-collapsed .sidebar .form-control-custom,
.sidebar-collapsed .sidebar .px-3 {
    display: none !important;
}

.sidebar-collapsed .sidebar::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* ─── CARD ─── */
.card-metric {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 18px 20px;
    height: 100%;
    transition: background 0.3s, border-color 0.3s;
}
.card-metric .label { font-size: 14px; color: var(--text-muted); }
.card-metric .value { font-size: 28px; font-weight: 700; color: var(--text-primary); }

/* ─── TABLE ─── */
.table-custom {
    background: var(--bg-table);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.table-custom th {
    background: var(--bg-table-header);
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}
.table-custom td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.table-custom tr:last-child td { border-bottom: none; }

/* ─── FIX TABEL LIGHT MODE ─── */
body.light-mode .table-dark,
body.light-mode .table-dark tbody,
body.light-mode .table-dark tr,
body.light-mode .table-dark td,
body.light-mode .table-dark th,
body.light-mode .table-custom,
body.light-mode .table-custom tbody,
body.light-mode .table-custom tr,
body.light-mode .table-custom td,
body.light-mode .table-custom th {
    background-color: #ffffff !important;
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}
body.light-mode .table-dark thead th,
body.light-mode .table-custom thead th {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border-bottom: 2px solid #e2e8f0 !important;
}
body.light-mode .table-dark tbody tr:hover,
body.light-mode .table-custom tbody tr:hover {
    background-color: #f8fafc !important;
}
body.light-mode .table-dark tbody td,
body.light-mode .table-custom tbody td {
    color: #334155 !important;
    border-bottom: 1px solid #e2e8f0 !important;
}
body.light-mode table {
    background-color: #ffffff !important;
    color: #1e293b !important;
}
body.light-mode table thead th {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
}
body.light-mode table tbody td {
    color: #334155 !important;
}
body.light-mode table tbody tr:hover {
    background-color: #f8fafc !important;
}

/* ─── BADGE ROI ─── */
.roi-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 13px;
    color: #fff !important;
    text-align: center;
    min-width: 70px;
}
.roi-badge-high {
    background-color: #34d399 !important;
}
.roi-badge-medium {
    background-color: #fbbf24 !important;
    color: #0b0e14 !important;
}
.roi-badge-low {
    background-color: #f87171 !important;
}
body.light-mode .roi-badge-high {
    background-color: #059669 !important;
}
body.light-mode .roi-badge-medium {
    background-color: #d97706 !important;
    color: #fff !important;
}
body.light-mode .roi-badge-low {
    background-color: #dc2626 !important;
}

/* ─── BUTTONS ─── */
.btn-outline-light {
    border-color: var(--border-light);
    color: var(--text-secondary);
}
.btn-outline-light:hover {
    background: var(--border-color);
    color: var(--text-primary);
}
.form-control-custom {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.form-control-custom:focus {
    box-shadow: none;
    border-color: #3b82f6;
}
.alert {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.text-muted { color: var(--text-muted) !important; }
.badge-status { background: #34d399; color: #0b0e14; }
.badge-meta { background: #1877f2; color: #fff; }
.badge-publisher { background: #f59e0b; color: #0b0e14; }
.badge-advertiser { background: #8b5cf6; color: #fff; }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── MOBILE ─── */
.mobile-toggle { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 280px !important;
        height: 100vh !important;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-right: 1px solid var(--border-color);
        padding-top: 60px;
        background: var(--bg-sidebar);
        box-shadow: var(--shadow);
        overflow-y: auto;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-collapsed .sidebar {
        transform: translateX(-100%) !important;
        width: 280px !important;
    }
    .sidebar-collapsed .sidebar.open {
        transform: translateX(0) !important;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        transition: opacity 0.3s ease;
    }
    .sidebar-overlay.show {
        display: block;
    }
    .mobile-toggle {
        display: block !important;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1060;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 8px 12px;
        font-size: 24px;
        color: var(--text-primary);
        cursor: pointer;
        box-shadow: var(--shadow);
    }
    .main-content {
        padding: 70px 15px 15px 15px !important;
    }
    .card-metric .value {
        font-size: 20px !important;
    }
    .card-metric .label {
        font-size: 12px !important;
    }
    .table-custom {
        overflow-x: auto !important;
        display: block !important;
        white-space: nowrap !important;
    }
    .table-custom table {
        min-width: 600px !important;
    }
    .row.g-2 .col-auto {
        width: 100% !important;
        flex: 0 0 100% !important;
    }
    .row.g-2 .col-auto select,
    .row.g-2 .col-auto input,
    .row.g-2 .col-auto button {
        width: 100% !important;
    }
    .col-lg-7, .col-lg-5 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    .d-flex.justify-content-between {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    .footer-bar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 70px 10px 10px 10px !important;
    }
    .card-metric {
        padding: 10px 12px !important;
        border-radius: 12px !important;
    }
    .card-metric .value {
        font-size: 16px !important;
    }
    .card-metric .label {
        font-size: 10px !important;
    }
    .card-metric .label i {
        font-size: 12px !important;
    }
    .card-metric[style*="height:270px"] {
        height: auto !important;
        min-height: 200px !important;
    }
    #roiChart {
        height: 150px !important;
    }
    .row.g-2.mb-3 {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 6px !important;
        padding-bottom: 6px !important;
    }
    .row.g-2.mb-3 .col-auto {
        flex: 0 0 auto !important;
        width: auto !important;
    }
    .row.g-2.mb-3 select,
    .row.g-2.mb-3 input,
    .row.g-2.mb-3 button {
        font-size: 11px !important;
        padding: 4px 10px !important;
        min-width: 80px !important;
    }
    .col-6 h6 {
        font-size: 12px !important;
        margin-bottom: 4px !important;
    }
    .col-6 .d-flex.justify-content-between {
        font-size: 11px !important;
        padding: 2px 0 !important;
    }
    .col-6 .d-flex.justify-content-between span {
        font-size: 11px !important;
    }
    .table-custom table {
        min-width: 500px !important;
    }
    .table-custom th,
    .table-custom td {
        padding: 6px 8px !important;
        font-size: 11px !important;
    }
    h1.h4 {
        font-size: 16px !important;
    }
    .text-muted {
        font-size: 11px !important;
    }
    .btn-sm {
        font-size: 10px !important;
        padding: 2px 8px !important;
    }
}