/* ============================================================
   DASHBOARD CSS — SELOMAS
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --purple: #8b5cf6;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;

    --text-primary: #0f172a;
    --text-muted: #64748b;
    --text-sidebar: #cbd5e1;

    --border: #e2e8f0;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

    --sidebar-w: 240px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 16px 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform .3s ease;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 20px;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
}

.brand-icon { font-size: 24px; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0 12px;
}

.nav-section {
    padding: 16px 12px 6px;
    font-size: 10px;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .15s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}

.nav-item i { font-size: 17px; width: 20px; text-align: center; }

.nav-item.text-danger { color: #f87171 !important; }
.nav-item.text-danger:hover { background: #7f1d1d; color: #fff !important; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    padding: 20px 24px;
    flex: 1;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all .15s;
}

.btn-icon:hover { background: #f8fafc; }

.badge-dot {
    position: absolute;
    top: 8px; right: 8px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

.btn-user {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 10px;
}

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    transition: all .2s;
    height: 100%;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: var(--primary);
}

.kpi-card.card-success::before { background: var(--success); }
.kpi-card.card-warning::before { background: var(--warning); }
.kpi-card.card-danger::before  { background: var(--danger); }
.kpi-card.card-info::before    { background: var(--info); }
.kpi-card.card-purple::before  { background: var(--purple); }

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    font-size: 26px;
    margin-bottom: 10px;
    display: block;
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.kpi-label {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.kpi-delta {
    font-size: 12px;
    margin-top: 8px;
    font-weight: 600;
}

.kpi-delta.up      { color: var(--success); }
.kpi-delta.down    { color: var(--danger); }
.kpi-delta.neutral { color: var(--text-muted); }

.kpi-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================================
   CARDS
   ============================================================ */
.chart-card,
.alert-card,
.table-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    height: 100%;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chart-card .card-header,
.alert-card .card-header,
.table-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
    font-weight: 600;
    font-size: 14.5px;
}

.chart-card .card-body,
.alert-card .card-body {
    padding: 16px 18px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table thead th {
    background: #f8fafc;
    font-size: 11.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 13.5px;
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

/* ============================================================
   BADGE
   ============================================================ */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    display: inline-block;
}

.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-info      { background: #cffafe; color: #155e75; }
.badge-primary   { background: #dbeafe; color: #1e40af; }
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-secondary { background: #e2e8f0; color: #334155; }
.badge-purple    { background: #ede9fe; color: #5b21b6; }

/* ============================================================
   ALERT LIST
   ============================================================ */
.alert-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 13.5px;
}

.alert-item:last-child { border-bottom: none; }

.alert-item .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-danger  { background: var(--danger); }
.dot-warning { background: var(--warning); }
.dot-info    { background: var(--info); }
.dot-success { background: var(--success); }

/* ============================================================
   PROGRESS MINI
   ============================================================ */
.progress-mini {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-mini > div {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width .4s ease;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 14px 24px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: auto;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .app-wrapper {
        margin-left: 0;
    }
    .main-content {
        padding: 16px;
    }
    .page-title { font-size: 18px; }
    .kpi-value { font-size: 22px; }
}

/* ============================================================
   SPIN ANIMATION (untuk refresh button)
   ============================================================ */
.spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ============================================================
   LOADING STATE
   ============================================================ */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 14px;
}

.loading::before {
    content: '⏳ ';
}

/* ============================================================
   ALERT SUCCESS
   ============================================================ */
.alert-item .dot-success { background: #10b981; }

.bg-warning-subtle { background-color: #fef3c7 !important; }

.badge-anomali {
    cursor: pointer;
    transition: all .2s;
    font-size: 11px;
}

.badge-anomali:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(245, 158, 11, .4);
}

/* ============================================================
   KPI NOTE — Inline YoY
   ============================================================ */
.kpi-note {
    font-size: 11.5px;
    color: #64748b;
    margin-top: 6px;
    line-height: 1.3;
}

.kpi-note .text-success { color: #10b981 !important; }
.kpi-note .text-danger  { color: #ef4444 !important; }
.kpi-note .text-muted   { color: #94a3b8 !important; }

/* ============================================================
   TAB NAVIGATION
   ============================================================ */
.tab-nav {
    display: flex;
    gap: 6px;
    background: #fff;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    margin-bottom: 16px;
}

.tab-nav::-webkit-scrollbar { height: 4px; }
.tab-nav::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13.5px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.tab-btn:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}

.tab-btn i { font-size: 15px; }

.tab-content { animation: fadeIn .3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .tab-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .tab-btn span { display: none; }
    .tab-btn i { font-size: 16px; }
}

/* ============================================================
   PETA (LEAFLET) — Modul Distribusi
   ============================================================ */
#mapMain {
    z-index: 1;
    border-radius: 0 0 12px 12px;
    background: #f1f5f9;
}

.leaflet-popup-content-wrapper {
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.leaflet-popup-content {
    margin: 12px 14px;
    font-family: 'Inter', sans-serif;
}

.leaflet-tooltip {
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.leaflet-tooltip-top:before {
    border-top-color: rgba(15, 23, 42, 0.9);
}

.map-legend {
    z-index: 1000;
}

/* Marker hover */
.leaflet-interactive {
    transition: all .2s;
}

.leaflet-interactive:hover {
    stroke-width: 3;
}

/* My location marker */
.my-location-marker {
    background: transparent;
    border: none;
}

/* District item panel */
.district-item {
    padding: 8px 10px;
    border-radius: 8px;
    transition: all .15s;
}

.district-item:hover {
    background: #f8fafc;
    transform: translateX(3px);
}

/* Map container responsive */
@media (max-width: 768px) {
    #mapMain {
        height: 400px !important;
    }
}

/* Cluster marker */
.marker-cluster-small {
    background-color: rgba(37, 99, 235, 0.6);
}
.marker-cluster-small div {
    background-color: rgba(37, 99, 235, 0.8);
    color: #fff;
}
.marker-cluster-medium {
    background-color: rgba(37, 99, 235, 0.6);
}
.marker-cluster-medium div {
    background-color: rgba(37, 99, 235, 0.8);
    color: #fff;
}
.marker-cluster-large {
    background-color: rgba(30, 64, 175, 0.7);
}
.marker-cluster-large div {
    background-color: rgba(30, 64, 175, 0.9);
    color: #fff;
}

/* Radio button group */
.btn-check:checked + .btn-outline-primary {
    background-color: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Tabel district */
#tableDistrict tbody tr {
    transition: background .2s;
}

#tableDistrict tbody tr:hover {
    background: #f8fafc;
}

/* Scrollbar custom untuk panel */
#topDistrictPanel::-webkit-scrollbar {
    width: 6px;
}
#topDistrictPanel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}