* { box-sizing: border-box; margin: 0; padding: 0; }
body, html { width: 100%; height: 100%; overflow: hidden; font-family: system-ui, -apple-system, sans-serif; background: #0f172a; }

.gis-app { position: relative; width: 100vw; height: 100vh; }
#map { width: 100%; height: 100%; z-index: 1; }

/* --- DARK MODE (DEFAULT UI GLASSMORPHISM) --- */
.glass-card {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    padding: 12px 14px;
    color: #f8fafc;
    transition: all 0.3s ease;
}

.top-bar {
    position: absolute; top: 16px; left: 16px; z-index: 1000;
    background: rgba(15, 23, 42, 0.88); backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 10px;
    padding: 10px 18px; display: flex; align-items: center; gap: 20px; color: #fff;
    transition: all 0.3s ease;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 15px; font-weight: 600; color: #ffffff; }
.pulse-dot { width: 8px; height: 8px; background-color: #22c55e; border-radius: 50%; box-shadow: 0 0 8px #22c55e; }

.header-select-wrapper {
    display: flex; align-items: center; gap: 6px;
    border-left: 1px solid rgba(255, 255, 255, 0.15); padding-left: 16px;
}
.header-select-wrapper .label { font-size: 9px; color: #94a3b8; font-weight: 600; }
.header-dropdown {
    background: rgba(255, 255, 255, 0.1); color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 6px;
    padding: 3px 8px; font-size: 11px; outline: none; cursor: pointer;
}
.header-dropdown option { background: #0f172a; color: #ffffff; }

.btn-theme-toggle {
    background: rgba(255, 255, 255, 0.12); color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 6px;
    padding: 4px 10px; font-size: 11px; font-weight: 600; cursor: pointer;
}

.header-info { display: flex; gap: 16px; border-left: 1px solid rgba(255,255,255,0.15); padding-left: 16px; }
.info-item { display: flex; flex-direction: column; }
.info-item .label { font-size: 9px; color: #94a3b8; }
.info-item .val { font-size: 12px; font-weight: 600; color: #e2e8f0; }
.status-online { color: #4ade80 !important; }
.status-error { color: #f87171 !important; }
.btn-clean-mode { background: #3b82f6; color: white; border: none; border-radius: 6px; padding: 6px 12px; font-size: 11px; font-weight: 600; cursor: pointer; }

/* Container Sidebar Kanan (CH Tertinggi + Search) */
.sidebar-right {
    position: absolute;
    right: 15px;
    top: 80px; /* Jarak dari Header Top Bar */
    z-index: 1000;
    width: 320px;
    
    /* FIX NABRAK GRAFIK: Batasi tinggi sidebar maksimal sampai di atas panel grafik */
    max-height: calc(100vh - 80px - 250px); /* 100vh - (top offset) - (tinggi panel grafik + gap) */
    display: flex;
    flex-direction: column;
}

/* Biar card-nya memanfaatkan sisa tinggi yang ada secara fleksibel */
.ranking-card.combined-card {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow: hidden; /* Menjaga sudut rounded card tetap rapi */
}

/* Isi list di dalam card akan auto-scroll kalau stasiunnya banyak */
.ranking-card.combined-card .card-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}
.card-header { font-size: 13px; font-weight: 700; color: #f8fafc; display: flex; justify-content: space-between; align-items: center; }
.header-title-group { display: flex; align-items: center; gap: 8px; }
.badge-max { background: #ef4444; color: white; font-size: 11px; padding: 2px 8px; border-radius: 12px; }
.btn-toggle-card { background: rgba(255, 255, 255, 0.1); border: none; width: 22px; height: 22px; border-radius: 4px; font-size: 14px; font-weight: bold; color: #cbd5e1; cursor: pointer; display: flex; align-items: center; justify-content: center; }

.search-box { position: relative; }
.search-box input { width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); background: rgba(0,0,0,0.2); color: #fff; font-size: 12px; outline: none; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: #1e293b; border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; margin-top: 4px; max-height: 180px; overflow-y: auto; z-index: 1010; display: none; }
.selected-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.station-chip { background: #3b82f6; color: white; padding: 3px 8px; border-radius: 6px; font-size: 11px; display: flex; align-items: center; gap: 6px; }
.station-chip button { background: none; border: none; color: white; cursor: pointer; }

.ranking-card { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ranking-card .card-body { flex: 1; overflow-y: auto; }
.ranking-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-radius: 6px; border: none; background: transparent; width: 100%; cursor: pointer; text-align: left; }
.ranking-item:hover { background: rgba(255, 255, 255, 0.08); }
.ranking-number { font-size: 11px; font-weight: 700; color: #94a3b8; width: 20px; }
.ranking-name { font-size: 12px; font-weight: 600; color: #f1f5f9; }
.ranking-city { font-size: 10px; color: #94a3b8; }
.ranking-value { font-size: 12px; font-weight: 700; }

/* Legenda BMKG (Posisi Kiri Bawah) */
.map-legend { 
    position: absolute; bottom: 260px; left: 16px; z-index: 1000; padding: 10px 14px; 
    background: rgba(15, 23, 42, 0.88); color: white; border-radius: 10px;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.legend-title { font-size: 11px; font-weight: 700; color: #e2e8f0; }
.legend-scale { display: flex; flex-direction: column; gap: 4px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 10px; color: #cbd5e1; }
.legend-item .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Panel Grafik Bawah */
.bottom-panel { 
    position: absolute; bottom: 16px; left: 16px; right: 16px; z-index: 1000; height: 230px; 
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chart-card { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.chart-header { display: flex; justify-content: space-between; align-items: center; }
.chart-title span { font-size: 13px; font-weight: 700; color: #f8fafc; }
.chart-title small { font-size: 10px; color: #94a3b8; display: block; }
.chart-actions { display: flex; align-items: center; gap: 8px; }
.select-wrapper { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #cbd5e1; }
.select-wrapper select { padding: 4px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.2); font-size: 11px; background: rgba(0,0,0,0.3); color: #fff; }
.btn-action { padding: 4px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.1); color: #fff; font-size: 11px; font-weight: 600; cursor: pointer; }
.btn-action.danger { color: #ef4444; border-color: #fca5a5; background: rgba(239, 68, 68, 0.2); }
.chart-body { flex: 1; position: relative; min-height: 0; }
.chart-wrapper { width: 100%; height: 100%; }

/* Minimized State */
.bottom-panel.minimized { height: 48px !important; }
.bottom-panel.minimized .chart-body { display: none !important; }
.gis-app.chart-minimized .map-legend { bottom: 74px !important; }
.glass-card.minimized .card-body { display: none !important; }

/* --- LIGHT THEME STYLING OVERRIDE --- */
body.light-theme .glass-card {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: #0f172a !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.12) !important;
}
body.light-theme .top-bar {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: #0f172a !important;
}
body.light-theme .brand h1,
body.light-theme .card-header,
body.light-theme .chart-title span,
body.light-theme .legend-title { color: #0f172a !important; }

body.light-theme .header-dropdown,
body.light-theme .btn-theme-toggle {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}
body.light-theme .header-dropdown option { background: #ffffff !important; color: #0f172a !important; }
body.light-theme .info-item .label,
body.light-theme .header-select-wrapper .label,
body.light-theme .chart-title small,
body.light-theme .legend-item,
body.light-theme .ranking-number,
body.light-theme .ranking-city,
body.light-theme .select-wrapper { color: #64748b !important; }

body.light-theme .info-item .val { color: #0f172a !important; }
body.light-theme .search-box input { background: #ffffff !important; color: #0f172a !important; border-color: #cbd5e1 !important; }
body.light-theme .search-results { background: #ffffff !important; border-color: #cbd5e1 !important; }
body.light-theme .ranking-name { color: #1e293b !important; }
body.light-theme .ranking-item:hover { background: rgba(0, 0, 0, 0.05) !important; }
body.light-theme .btn-toggle-card { background: rgba(0, 0, 0, 0.06) !important; color: #475569 !important; }
body.light-theme .select-wrapper select,
body.light-theme .btn-action { background: #ffffff !important; color: #0f172a !important; border-color: #cbd5e1 !important; }

.clean-mode .sidebar-right,
.clean-mode .bottom-panel,
.clean-mode .map-legend { opacity: 0; pointer-events: none; transform: translateY(20px); }

/* Styling Dot Legenda bundar solid */
.legend-item .dot { 
    width: 10px; 
    height: 10px; 
    min-width: 10px;
    min-height: 10px;
    border-radius: 50%; /* Membuat bentuk lingkaran sempurna */
    display: inline-block; 
    flex-shrink: 0;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5); /* Penjelas batas lingkaran */
}

/* Header Actions Right Group */
.card-actions-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Tombol Icon Search */
.btn-icon-search {
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon-search:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Box Input Search Inline */
.search-box-inline {
    margin-bottom: 8px;
    position: relative;
}

.search-box-inline input {
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(15, 23, 42, 0.6);
    color: #fff;
    outline: none;
}