/* Google Font */
body {
    font-family: 'Inter', sans-serif;
    background-color: #050a14 !important;
    /* Deep dark background */
    color: #e2e8f0;
}

/* Background Pattern/Gradient */
.body-bg-custom {
    background-image: radial-gradient(circle at 15% 50%, rgba(9, 14, 52, 0.5), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(20, 40, 60, 0.4), transparent 25%);
    background-blend-mode: multiply;
    background-attachment: fixed;
}

/* Brand Accents */
.text-brand-orange {
    color: #f58220;
    text-shadow: 0 0 10px rgba(245, 130, 32, 0.5);
}

.text-brand-blue {
    color: #38bdf8;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.border-brand-orange {
    border-color: rgba(245, 130, 32, 0.4) !important;
}

/* Light Theme Overrides */
[data-bs-theme="light"] body {
    background-color: #f8fafc !important;
    color: #0f172a;
}

[data-bs-theme="light"] .body-bg-custom {
    background-image: radial-gradient(circle at 15% 50%, rgba(226, 232, 240, 0.8), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(241, 245, 249, 0.8), transparent 25%);
    background-blend-mode: normal;
}

[data-bs-theme="light"] .glass-panel {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .glass-navbar {
    background: rgba(255, 255, 255, 0.85) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .text-brand-orange {
    color: #ea580c;
    text-shadow: none;
}

[data-bs-theme="light"] .text-brand-blue {
    color: #0284c7;
    text-shadow: none;
}

[data-bs-theme="light"] .border-brand-orange {
    border-color: #ea580c !important;
}

[data-bs-theme="light"] .brand-icon {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #ea580c;
}

[data-bs-theme="light"] .kpi-card::before {
    opacity: 1;
}

[data-bs-theme="light"] .kpi-card.emerald::before {
    background: linear-gradient(to bottom, #0284c7, transparent);
}

[data-bs-theme="light"] .kpi-card.amber::before {
    background: linear-gradient(to bottom, #f59e0b, transparent);
}

[data-bs-theme="light"] .kpi-card.purple::before {
    background: linear-gradient(to bottom, #8b5cf6, transparent);
}

[data-bs-theme="light"] .kpi-title {
    color: #64748b;
}

[data-bs-theme="light"] .kpi-value {
    color: #0f172a;
}

[data-bs-theme="light"] .kpi-icon {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .table-glass {
    color: #334155;
}

[data-bs-theme="light"] .table-glass thead th {
    background: rgba(0, 0, 0, 0.03);
    color: #475569;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .table-glass tbody td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .table-glass tbody tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

[data-bs-theme="light"] .badge-glass {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: #334155;
}

[data-bs-theme="light"] .badge-glass-super {
    background: #f3e8ff;
    border-color: #d8b4fe;
    color: #7e22ce;
}

[data-bs-theme="light"] .badge-glass-domestik {
    background: #e0f2fe;
    border-color: #bae6fd;
    color: #0369a1;
}

[data-bs-theme="light"] .btn-outline-light {
    color: #334155;
    border-color: #cbd5e1;
}

[data-bs-theme="light"] .btn-outline-light:hover {
    background: #f1f5f9;
    color: #0f172a;
}

[data-bs-theme="light"] .text-light {
    color: #0f172a !important;
}

[data-bs-theme="light"] .text-muted {
    color: #64748b !important;
}

[data-bs-theme="light"] .bg-dark.rounded-circle {
    background-color: #f1f5f9 !important;
}

/* Dashboard Export wrapper fix */
.dashboard-export-wrapper {
    background: inherit;
}

/* Curah Hujan Light Overrides */
[data-bs-theme="light"] .ch-rendah {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #d97706 !important;
}

[data-bs-theme="light"] .ch-sedang {
    background-color: rgba(2, 132, 199, 0.15) !important;
    color: #0369a1 !important;
}

[data-bs-theme="light"] .ch-tinggi {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #047857 !important;
}

[data-bs-theme="light"] .ch-sangat-tinggi {
    background-color: rgba(4, 120, 87, 0.2) !important;
    color: #064e3b !important;
}


/* Brand Icon */
.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(245, 130, 32, 0.2), rgba(0, 0, 0, 0));
    border: 1px solid rgba(245, 130, 32, 0.3);
    color: #f58220;
}

/* Glassmorphism Panels */
.glass-panel {
    background: rgba(16, 22, 36, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-navbar {
    background: rgba(10, 15, 26, 0.8) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* KPI Cards */
.kpi-card {
    height: 100%;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 240, 255, 0.15);
    border-color: rgba(0, 240, 255, 0.2);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #f58220, transparent);
    opacity: 0.7;
}

.kpi-card.emerald::before {
    background: linear-gradient(to bottom, #38bdf8, transparent);
}

.kpi-card.amber::before {
    background: linear-gradient(to bottom, #ffbe0b, transparent);
}

.kpi-card.purple::before {
    background: linear-gradient(to bottom, #9d4edd, transparent);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.kpi-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.5px;
}

.kpi-unit {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 400;
}

/* Tables */
.table-glass {
    color: #e2e8f0;
}

.table-glass thead th {
    background: rgba(255, 255, 255, 0.02);
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 16px;
    white-space: nowrap;
}

.table-glass tbody td {
    background: transparent;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
    font-size: 0.9rem;
}

.table-glass tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
    padding: 6px 10px;
}

.badge-glass-super {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.3);
    color: #bae6fd;
}

.badge-glass-domestik {
    background: rgba(245, 130, 32, 0.15);
    border-color: rgba(245, 130, 32, 0.3);
    color: #fbd38d;
}

/* Progress / Gauges */
.progress-glass {
    background: rgba(255, 255, 255, 0.05);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.progress-glass .progress-bar {
    background: linear-gradient(90deg, #f58220, #facc15);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Curah Hujan Highlight Base (Dark Mode) */
.ch-rendah {
    background-color: rgba(255, 190, 11, 0.15) !important;
    color: #ffbe0b !important;
    font-weight: 600;
}

.ch-sedang {
    background-color: rgba(0, 240, 255, 0.15) !important;
    color: #00f0ff !important;
    font-weight: 600;
}

.ch-tinggi {
    background-color: rgba(0, 255, 136, 0.15) !important;
    color: #00ff88 !important;
    font-weight: 600;
}

.ch-sangat-tinggi {
    background-color: rgba(0, 180, 90, 0.25) !important;
    color: #00ff88 !important;
    font-weight: 700;
}

/* Legend styling specifically for Curah Hujan */
.ch-legend-box {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-block;
}

/* Hover effects for rainfall row */
.ch-row-hover {
    transition: all 0.2s ease;
}

.ch-row-hover:hover {
    background-color: rgba(255, 255, 255, 0.05);
    transform: scale(1.005);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Admin Layout CSS */
.admin-sidebar {
    width: 280px;
    background: rgba(10, 15, 26, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 1045;
    transition: transform 0.3s ease;
}

.admin-main {
    margin-left: 280px;
    min-height: 100vh;
    background: #0f172a;
    transition: margin-left 0.3s ease;
}

.admin-topbar {
    background: rgba(10, 15, 26, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 1030;
    padding: 1rem;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
}

.admin-sidebar .nav-link.active {
    background: rgba(245, 130, 32, 0.1);
    color: #f58220 !important;
    border-right: 3px solid #f58220;
}

.admin-sidebar .nav-link:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    display: none;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* Admin Light Theme Overrides */
[data-bs-theme="light"] .admin-sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .admin-main {
    background: #f8fafc;
}

[data-bs-theme="light"] .admin-topbar {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .admin-sidebar .nav-link:not(.active),
[data-bs-theme="light"] .admin-sidebar .text-white {
    color: #475569 !important;
}

[data-bs-theme="light"] .admin-sidebar .nav-link:hover:not(.active) {
    background: rgba(0, 0, 0, 0.03);
}

[data-bs-theme="light"] .admin-sidebar hr.border-secondary {
    border-color: rgba(0, 0, 0, 0.1) !important;
}

[data-bs-theme="light"] .sidebar-collapse-btn {
    color: #64748b !important;
}

[data-bs-theme="light"] .sidebar-collapse-btn:hover {
    background: rgba(245, 130, 32, 0.1);
    color: #ea580c !important;
}

[data-bs-theme="light"] .sidebar-hover-expand .admin-sidebar {
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.12);
}

/* Mobile Responsiveness for Admin */
@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.show {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0;
    }

    /* Hide collapse button on mobile */
    .sidebar-collapse-btn {
        display: none !important;
    }
}

/* ─── Sidebar Collapse/Expand ─── */
.admin-sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
}

.admin-main {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapse-btn {
    transition: opacity 0.2s ease;
    font-size: 0.85rem;
    opacity: 0.5;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.sidebar-collapse-btn:hover {
    opacity: 1;
    background: rgba(245, 130, 32, 0.15);
    color: #f58220 !important;
}

.sidebar-text,
.sidebar-brand-text,
.sidebar-chevron {
    transition: opacity 0.2s ease, width 0.2s ease;
    white-space: nowrap;
}

/* ─── Collapsed State ─── */
@media (min-width: 992px) {
    .sidebar-collapsed .admin-sidebar {
        width: 70px;
        padding: 0.75rem !important;
    }

    .sidebar-collapsed .admin-main {
        margin-left: 70px;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-text,
    .sidebar-collapsed .admin-sidebar .sidebar-brand-text,
    .sidebar-collapsed .admin-sidebar .sidebar-chevron {
        opacity: 0;
        width: 0;
        overflow: hidden;
        display: inline-block;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-submenu {
        display: none;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-toggle {
        justify-content: center !important;
        padding: 0.55rem 0;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-toggle span {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-toggle span i.fa-fw {
        margin-right: 0 !important;
        font-size: 1.1rem;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-collapse-btn {
        display: none;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-brand {
        justify-content: center;
    }

    .sidebar-collapsed .admin-sidebar .sidebar-brand-icon {
        margin-right: 0 !important;
    }

    .sidebar-collapsed .admin-sidebar>div:first-child {
        justify-content: center !important;
    }

    .sidebar-collapsed .admin-sidebar hr {
        margin: 0.5rem 0;
    }

    /* Hide user profile details when collapsed */
    .sidebar-collapsed .admin-sidebar .dropdown .lh-1,
    .sidebar-collapsed .admin-sidebar .dropdown .mt-2 {
        display: none;
    }

    .sidebar-collapsed .admin-sidebar .dropdown .d-flex {
        justify-content: center;
    }

    /* ─── Hover Expand State ─── */
    .sidebar-hover-expand .admin-sidebar {
        width: 280px;
        padding: 0.75rem 1rem !important;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.4);
        z-index: 1050;
    }

    .sidebar-hover-expand .admin-sidebar .sidebar-collapse-btn {
        display: flex;
    }

    .sidebar-hover-expand .admin-sidebar .sidebar-text,
    .sidebar-hover-expand .admin-sidebar .sidebar-brand-text,
    .sidebar-hover-expand .admin-sidebar .sidebar-chevron {
        opacity: 1;
        width: auto;
    }

    .sidebar-hover-expand .admin-sidebar .sidebar-submenu {
        display: block;
    }

    .sidebar-hover-expand .admin-sidebar .sidebar-toggle {
        justify-content: space-between !important;
        padding: 0.55rem 0.75rem;
    }

    .sidebar-hover-expand .admin-sidebar .sidebar-toggle span i.fa-fw {
        margin-right: 0.5rem !important;
        font-size: inherit;
    }

    .sidebar-hover-expand .admin-sidebar .sidebar-brand-icon {
        margin-right: 0.5rem !important;
    }

    .sidebar-hover-expand .admin-sidebar>div:first-child {
        justify-content: space-between !important;
    }

    .sidebar-hover-expand .admin-sidebar .dropdown .lh-1,
    .sidebar-hover-expand .admin-sidebar .dropdown .mt-2 {
        display: block;
    }

    .sidebar-hover-expand .admin-sidebar .dropdown .d-flex {
        justify-content: flex-start;
    }
}