:root {
    --bg-dark: #0f172a;
    --panel-bg: rgba(15, 23, 42, 0.88);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #ef4444;
    --accent-hover: #dc2626;
    --accent-glow: rgba(239, 68, 68, 0.3);
    --glass-border: rgba(255, 255, 255, 0.1);
    --list-hover: rgba(255, 255, 255, 0.08);
    --stat-bg: rgba(255, 255, 255, 0.05);
    --track-bg: #334155;
    --input-bg: rgba(255, 255, 255, 0.06);
}

body.light-mode {
    --bg-dark: #f1f5f9;
    --panel-bg: rgba(255, 255, 255, 0.92);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --glass-border: rgba(0, 0, 0, 0.08);
    --list-hover: rgba(0, 0, 0, 0.04);
    --stat-bg: rgba(0, 0, 0, 0.03);
    --accent-glow: rgba(239, 68, 68, 0.15);
    --track-bg: #cbd5e1;
    --input-bg: rgba(0, 0, 0, 0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
html { scroll-behavior: smooth; }

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    overflow-y: auto !important;
    scroll-behavior: smooth;
    transition: background-color 0.4s ease, color 0.4s ease;
}

#map { position: absolute !important; top: 0; left: 0; height: 100%; width: 100%; z-index: 1; }

/* ===================== */
/* Theme Toggle          */
/* ===================== */
.theme-toggle-btn {
    background: var(--panel-bg); border: 1px solid var(--glass-border);
    color: var(--text-primary); width: 38px; height: 38px; border-radius: 50%;
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    transition: transform 0.2s ease, background 0.3s ease;
}
.theme-toggle-btn:hover { transform: scale(1.1); }

/* ===================== */
/* Coordinate Display    */
/* ===================== */
.coord-display {
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    z-index: 1000; background: var(--panel-bg); backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border); border-radius: 8px;
    padding: 6px 14px; font-size: 0.72rem; color: var(--text-secondary);
    font-family: 'Inter', monospace; letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: background 0.3s, border-color 0.3s;
}

/* ===================== */
/* Heatmap Legend         */
/* ===================== */
.legend-box {
    position: absolute; bottom: 50px; right: 20px; z-index: 1000;
    background: var(--panel-bg); backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border); border-radius: 10px;
    padding: 12px 14px; width: 140px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: background 0.3s, border-color 0.3s;
}
.legend-title {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-secondary); font-weight: 600; margin-bottom: 8px;
}
.legend-bar {
    height: 10px; border-radius: 4px;
    background: linear-gradient(to right, #fbbf24, #f97316, #ef4444);
    margin-bottom: 4px;
}
.legend-labels {
    display: flex; justify-content: space-between;
    font-size: 0.65rem; color: var(--text-secondary);
}

/* ===================== */
/* Panel UI              */
/* ===================== */
.panel-info {
    position: absolute; top: 20px; left: 20px; z-index: 1000;
    width: 320px; max-height: calc(100vh - 40px);
    overflow-y: auto; overflow-x: hidden;
    background: var(--panel-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); border-radius: 16px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    color: var(--text-primary);
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}
body.light-mode .panel-info { box-shadow: 0 10px 30px rgba(0,0,0,0.08); }
.panel-info::-webkit-scrollbar { width: 4px; }
.panel-info::-webkit-scrollbar-track { background: transparent; }
.panel-info::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.3); border-radius: 4px; }

.panel-info h1 {
    font-size: 1.25rem; font-weight: 800; margin-bottom: 2px;
    background: linear-gradient(135deg, #fbbf24, #ef4444);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    line-height: 1.3;
}
.panel-subtitle { color: var(--text-secondary); font-size: 0.8rem; margin-bottom: 14px; }

/* ===================== */
/* Search Box            */
/* ===================== */
.search-box {
    display: flex; gap: 6px; margin-bottom: 16px;
}
.search-input {
    flex: 1; padding: 8px 12px;
    background: var(--input-bg); border: 1px solid var(--glass-border);
    border-radius: 8px; font-size: 0.82rem; color: var(--text-primary);
    outline: none; transition: border-color 0.3s, box-shadow 0.3s;
}
.search-input::placeholder { color: var(--text-secondary); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.btn-search {
    flex-shrink: 0; width: 34px; height: 34px;
    background: var(--accent); border: none; border-radius: 8px;
    color: white; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.2s;
}
.btn-search:hover { opacity: 0.85; }

/* ===================== */
/* Slider Section        */
/* ===================== */
.slider-container { margin-bottom: 18px; }
.slider-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.slider-header label { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); flex-shrink: 1; }

.btn-play {
    flex-shrink: 0; background: var(--stat-bg); border: 1px solid var(--glass-border);
    border-radius: 50%; width: 30px; height: 30px; min-width: 30px;
    cursor: pointer; display: flex; justify-content: center; align-items: center;
    color: var(--text-primary); transition: transform 0.2s, background 0.2s;
}
.btn-play:hover { transform: scale(1.15); background: var(--list-hover); }

.highlight { color: var(--accent); font-weight: 800; }

/* Range Slider */
input[type=range] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px; background: var(--track-bg);
    border-radius: 2px; outline: none; margin: 6px 0; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    height: 16px; width: 16px; border-radius: 50%;
    background: var(--accent); cursor: pointer; border: none;
    box-shadow: 0 0 8px var(--accent-glow);
}
input[type=range]::-moz-range-thumb {
    height: 16px; width: 16px; border-radius: 50%;
    background: var(--accent); cursor: pointer; border: none;
    box-shadow: 0 0 8px var(--accent-glow);
}
.slider-labels { display: flex; justify-content: space-between; margin-top: 4px; font-size: 0.7rem; color: var(--text-secondary); }

/* ===================== */
/* Stats Box             */
/* ===================== */
.stats { margin-bottom: 14px; }
.stat-box {
    background: var(--stat-bg); border: 1px solid var(--glass-border);
    padding: 14px; border-radius: 10px; text-align: center;
    transition: background 0.3s ease;
}
.stat-value { display: block; font-size: 1.8rem; font-weight: 800; color: #fbbf24; line-height: 1.2; }
.stat-label { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; display: block; }

/* ===================== */
/* Buttons               */
/* ===================== */
.btn-outline {
    width: 100%; padding: 9px; background: transparent;
    border: 1px solid var(--accent); color: var(--accent);
    border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.82rem;
    transition: all 0.3s ease; margin-bottom: 14px;
}
.btn-outline:hover { background: var(--accent); color: white; box-shadow: 0 4px 12px var(--accent-glow); }

/* ===================== */
/* Hotspot List          */
/* ===================== */
.hotspot-list-container { border-top: 1px solid var(--glass-border); padding-top: 12px; }
.list-title { font-size: 0.7rem; margin-bottom: 8px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; }
.hotspot-list { max-height: 200px; overflow-y: auto; padding-right: 4px; }
.hotspot-list::-webkit-scrollbar { width: 3px; }
.hotspot-list::-webkit-scrollbar-track { background: transparent; }
.hotspot-list::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.4); border-radius: 3px; }

.hotspot-item {
    padding: 8px 10px; border-radius: 6px; background: transparent;
    cursor: pointer; border-bottom: 1px solid var(--glass-border);
    transition: background 0.2s, transform 0.15s;
    font-size: 0.78rem; color: var(--text-secondary); line-height: 1.4;
}
.hotspot-item:last-child { border-bottom: none; }
.hotspot-item:hover { background: var(--list-hover); transform: translateX(3px); }
.hotspot-item .item-coords { color: var(--accent); font-weight: 600; font-size: 0.78rem; display: block; margin-bottom: 1px; }
.hotspot-item .item-year { color: var(--text-secondary); font-size: 0.72rem; }
.hotspot-empty { text-align: center; padding: 16px 10px; color: var(--text-secondary); font-size: 0.8rem; }

/* ===================== */
/* Leaflet Overrides     */
/* ===================== */
.leaflet-container { background-color: var(--bg-dark) !important; transition: background-color 0.4s ease; }

.leaflet-control-zoom {
    border: none !important; box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-radius: 8px !important; overflow: hidden;
}
.leaflet-control-zoom a {
    background-color: var(--panel-bg) !important; color: var(--text-primary) !important;
    border: none !important; border-bottom: 1px solid var(--glass-border) !important;
    backdrop-filter: blur(12px); width: 32px !important; height: 32px !important;
    line-height: 32px !important; font-size: 15px !important; transition: background 0.2s;
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { background-color: var(--list-hover) !important; }

.leaflet-top {
    margin-top: 75px !important; /* Mencegah tertutup oleh main-header */
}

.leaflet-control-layers {
    border: none !important; box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-radius: 8px !important; background: var(--panel-bg) !important;
    color: var(--text-primary) !important; backdrop-filter: blur(12px);
}
.leaflet-control-layers-toggle { width: 36px !important; height: 36px !important; }
.leaflet-control-layers-expanded { padding: 8px 12px !important; }
.leaflet-control-layers label { color: var(--text-primary) !important; font-size: 0.82rem; }

.leaflet-control-attribution {
    background: var(--panel-bg) !important; color: var(--text-secondary) !important;
    font-size: 10px !important; backdrop-filter: blur(8px);
}
.leaflet-control-attribution a { color: var(--text-secondary) !important; }

/* ===================== */
/* Modul Cerdas UI       */
/* ===================== */
.smart-modules-container, .data-report-container {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--stat-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
}
.module-toggles, .report-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toggle-btn {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding: 6px 0;
}
.toggle-btn input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle-slider {
    width: 36px;
    height: 20px;
    background-color: var(--track-bg);
    border-radius: 20px;
    position: relative;
    transition: 0.3s;
    flex-shrink: 0;
}
.toggle-slider:before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
}
.toggle-btn input:checked + .toggle-slider {
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}
.toggle-btn input:checked + .toggle-slider:before {
    transform: translateX(16px);
}
.toggle-label {
    margin-left: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.toggle-label i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
    transition: color 0.3s;
}
.toggle-btn input:checked ~ .toggle-label i {
    color: var(--accent);
}

/* Custom Marker Icons */
.custom-div-icon {
    background: transparent;
    border: none;
}
.marker-tent {
    background-color: #22c55e;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    border: 2px solid white;
}
.marker-health {
    background-color: #ef4444;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    border: 2px solid white;
}
.marker-logistic {
    background-color: #eab308;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.5);
    border: 2px solid white;
}
.marker-excavator {
    background-color: #3b82f6;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    border: 2px solid white;
}

/* ===================== */
/* Responsive            */
/* ===================== */
@media (max-width: 768px) {
    .panel-info { width: calc(100vw - 24px); left: 12px; top: 12px; max-height: 50vh; padding: 16px; }
    .panel-info h1 { font-size: 1.1rem; }
    .stat-value { font-size: 1.5rem; }
    .hotspot-list { max-height: 100px; }
    .legend-box { display: none; }
    .coord-display { font-size: 0.65rem; padding: 4px 10px; }
}

/* ===================== */
/* Professional Layout   */
/* ===================== */
.hero-map { position: relative; height: 100vh; width: 100%; margin-top: 60px; height: calc(100vh - 60px); }

/* Header / Navbar */
.main-header { position: fixed; top: 0; left: 0; width: 100%; height: 60px; background: var(--panel-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 2000; display: flex; justify-content: space-between; align-items: center; padding: 0 40px; border-bottom: 1px solid var(--glass-border); box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.logo-title { font-size: 18px; font-weight: 800; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.logo-title i { font-size: 22px; }
.logo-title span { color: var(--text-primary); }
.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a { color: var(--text-primary); text-decoration: none; font-weight: 600; font-size: 14px; transition: 0.3s; }
.nav-links a:hover { color: var(--accent); }
.btn-login { background: var(--accent); padding: 8px 16px; border-radius: 6px; color: white !important; }
.btn-login:hover { background: var(--accent-hover); }

/* Adjust panel for header */
.panel-info { top: 80px; }

/* Scroll Indicator */
.scroll-indicator { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 1001; text-align: center; color: white; text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,0.8); animation: bounce 2s infinite; background: rgba(0,0,0,0.4); padding: 10px 20px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.2); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.scroll-indicator i { font-size: 20px; }
@keyframes bounce { 0%, 20%, 50%, 80%, 100% { transform: translateY(0) translateX(-50%); } 40% { transform: translateY(-10px) translateX(-50%); } 60% { transform: translateY(-5px) translateX(-50%); } }

/* Data Section */
.data-section { padding: 80px 0; background: var(--bg-dark); color: var(--text-primary); min-height: 100vh; position: relative; z-index: 2; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.section-header { text-align: center; margin-bottom: 50px; }
.section-header h2 { font-size: 32px; font-weight: 800; color: var(--accent); margin-bottom: 10px; }
.section-header p { font-size: 16px; color: var(--text-secondary); }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 60px; }
.stat-card { background: var(--panel-bg); border: 1px solid var(--glass-border); border-radius: 12px; padding: 25px; display: flex; align-items: center; gap: 20px; transition: 0.3s; }
.stat-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.1); border-color: var(--accent); }
.stat-icon { font-size: 40px; color: var(--accent); background: var(--accent-glow); width: 70px; height: 70px; display: flex; justify-content: center; align-items: center; border-radius: 12px; }
.stat-info h3 { font-size: 14px; color: var(--text-secondary); margin-bottom: 5px; font-weight: 600; }
.stat-number { font-size: 28px; font-weight: 800; color: var(--text-primary); margin-bottom: 2px; }
.stat-desc { font-size: 11px; color: var(--text-secondary); }

/* Data Table */
.data-table-container { background: var(--panel-bg); border-radius: 12px; border: 1px solid var(--glass-border); padding: 30px; margin-bottom: 60px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.table-header-info { margin-bottom: 25px; text-align: center; border-bottom: 1px solid var(--glass-border); padding-bottom: 20px; }
.table-header-info h3 { font-size: 20px; color: var(--accent); margin-bottom: 8px; }
.table-header-info p { font-size: 14px; color: var(--text-secondary); }
.table-responsive { overflow-x: auto; }
.styled-table { width: 100%; border-collapse: collapse; margin: 0; font-size: 14px; text-align: right; }
.styled-table thead tr { background-color: var(--track-bg); color: var(--text-primary); text-align: right; }
.styled-table th, .styled-table td { padding: 12px 15px; border-bottom: 1px solid var(--glass-border); }
.styled-table th:first-child, .styled-table td:first-child { text-align: left; font-weight: 600; }
.styled-table tbody tr { transition: background-color 0.2s; }
.styled-table tbody tr:hover { background-color: var(--list-hover); }
.total-row { font-weight: bold; color: var(--accent); background-color: var(--stat-bg); border-top: 2px solid var(--accent); }

/* Info Text */
.info-text { background: var(--stat-bg); padding: 30px; border-radius: 12px; border-left: 4px solid var(--accent); }
.info-text h3 { margin-bottom: 15px; font-size: 20px; }
.info-text p { line-height: 1.7; color: var(--text-secondary); }

/* Footer */
footer { padding: 30px 0; background: #000; color: #666; font-size: 13px; position: relative; z-index: 2; }
.text-center { text-align: center; }
