/* =====================================================
   base.css
   Style global yang dipakai di seluruh halaman:
     1. Reset dasar
     2. Section Divider
     3. Badge umum
     4. Gauge Popup (detail sensor)
     5. Guide Popup (panduan kategori AQI & AQHI)
   ===================================================== */


/* =====================================================
   1. RESET DASAR
   ===================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}


/* =====================================================
   2. SECTION DIVIDER
   Garis pemisah antar section dengan teks di tengah.
   Contoh: <div class="section-divider"><span>GRAFIK</span></div>
   ===================================================== */

.section-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 12px;
    margin: 4px 0 0;
}

/* Garis kiri & kanan teks */
.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #cbd5e1;
}

.section-divider span {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}


/* =====================================================
   3. BADGE UMUM
   Dipakai untuk label status kecil di berbagai tempat.
   ===================================================== */

.badge {
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
    white-space: nowrap;
}


/* =====================================================
   4. GAUGE POPUP
   Popup detail sensor yang muncul saat gauge diklik.
   Dipanggil via openPopup('aqi' | 'pm25' | 'pm10' | 'pm1' | 'polutan')
   ===================================================== */

/* Overlay gelap di belakang popup */
.popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.popup-overlay.active { display: flex; }

/* Kotak popup dengan animasi masuk */
.popup-box {
    background: #ffffff;
    border-radius: 24px;
    padding: 24px 22px 20px;
    width: 100%;
    max-width: 360px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    animation: popIn 0.22s ease;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

/* Tombol tutup (×) */
.popup-close {
    position: absolute;
    top: 14px; right: 16px;
    background: #f1f5f9;
    border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 14px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.popup-close:hover { background: #e2e8f0; color: #0f172a; }

/* Header: ikon + nama sensor */
.popup-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}
.popup-icon-wrap {
    width: 46px; height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.popup-title    { font-size: 18px; font-weight: 700; color: #0f172a; margin: 0 0 2px; }
.popup-subtitle { font-size: 13px; color: #64748b; margin: 0; }

/* Nilai besar & satuan */
.popup-value-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 10px;
}
.popup-big-value { font-size: 42px; font-weight: 800; color: #0f172a; line-height: 1; }
.popup-big-unit  { font-size: 16px; color: #64748b; }

/* Badge status */
.popup-status-badge {
    display: inline-block;
    padding: 5px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

/* Warna badge per kategori — dipakai juga oleh Guide Popup */
.status-good      { background: #22c55e; color: #fff; }
.status-moderate  { background: #f59e0b; color: #fff; }
.status-poor      { background: #f97316; color: #fff; }
.status-unhealthy { background: #ef4444; color: #fff; }
.status-severe    { background: #9333ea; color: #fff; }
.status-hazardous { background: #7f1d1d; color: #fff; }

/* Skala warna 6 segmen */
.popup-scale { margin-bottom: 18px; }

.popup-scale-bar {
    position: relative;
    display: flex;
    height: 10px;
    border-radius: 10px;
    overflow: visible;
    margin-bottom: 4px;
}

/* Segmen warna skala */
.scale-seg             { flex: 1; height: 100%; }
.scale-seg:first-child { border-radius: 10px 0 0 10px; }
.scale-seg:last-child  { border-radius: 0 10px 10px 0; }
.seg-good      { background: #22c55e; }
.seg-moderate  { background: #a3e635; }
.seg-poor      { background: #facc15; }
.seg-unhealthy { background: #f97316; }
.seg-severe    { background: #ef4444; }
.seg-hazardous { background: #7f1d1d; }

/* Jarum penunjuk posisi — left diatur via JS */
.scale-needle {
    position: absolute;
    top: -4px;
    width: 18px; height: 18px;
    background: #fff;
    border: 3px solid #0f172a;
    border-radius: 50%;
    transform: translateX(-50%);
    transition: left 0.4s ease;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Label & angka di bawah skala */
.popup-scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: #94a3b8;
    margin-top: 6px;
}
.popup-scale-numbers {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: #cbd5e1;
    margin-top: 2px;
}

/* Baris rata-rata (avg) — opsional, dipakai jika popup menampilkan historis */
.popup-avg-title { font-size: 13px; font-weight: 600; color: #334155; margin: 0 0 10px; }

.popup-avg-row { display: flex; gap: 10px; }

.avg-box {
    flex: 1;
    border-radius: 14px;
    padding: 10px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.avg-green  { background: #dcfce7; }
.avg-yellow { background: #fef9c3; }
.avg-pink   { background: #fee2e2; }

.avg-label { font-size: 11px; color: #64748b; }
.avg-val             { font-size: 22px; font-weight: 800; color: #0f172a; line-height: 1; }
.avg-green  .avg-val { color: #166534; }
.avg-yellow .avg-val { color: #854d0e; }
.avg-pink   .avg-val { color: #991b1b; }


/* =====================================================
   5. GUIDE POPUP
   Popup panduan kategori AQI & AQHI dengan Do's & Don'ts.
   Dipanggil via openGuidePopup('aqhi-low' | 'aqi-good' | dst)
   ===================================================== */

/* Overlay */
.guide-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 22, 36, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.guide-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Kotak popup dengan animasi scale */
.guide-popup {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        0 16px 48px rgba(15, 22, 36, 0.14),
        0 4px  16px rgba(15, 22, 36, 0.08);
    border: 1.5px solid #e2e6ef;
    transform: scale(0.94) translateY(12px);
    transition: transform 0.25s cubic-bezier(0.34, 1.36, 0.64, 1);
}
.guide-overlay.active .guide-popup {
    transform: scale(1) translateY(0);
}

/* Scrollbar tipis */
.guide-popup::-webkit-scrollbar       { width: 4px; }
.guide-popup::-webkit-scrollbar-track { background: transparent; }
.guide-popup::-webkit-scrollbar-thumb { background: #e2e6ef; border-radius: 99px; }

/* Garis warna di atas popup — warna diatur via JS */
.guide-popup-topbar {
    height: 5px;
    width: 100%;
    border-radius: 20px 20px 0 0;
}

.guide-popup-inner { padding: 20px 22px 24px; }

/* Header: ikon + judul + rentang */
.guide-popup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.guide-popup-head-left { display: flex; align-items: center; gap: 12px; }

/* Kotak ikon emoji */
.guide-popup-dot {
    width: 42px; height: 42px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.guide-popup-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f1624;
    line-height: 1.25;
}
.guide-popup-range {
    font-family: 'DM Mono', 'Courier New', monospace;
    font-size: 11px;
    color: #9aa3bb;
    margin-top: 2px;
}

/* Tombol tutup */
.guide-popup-close {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 1.5px solid #e2e6ef;
    background: #f7f8fc;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #5a6480;
    font-size: 13px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.guide-popup-close:hover { background: #e2e6ef; color: #0f1624; }

/* Deskripsi kondisi */
.guide-popup-desc {
    font-size: 13px;
    line-height: 1.68;
    color: #5a6480;
    margin-bottom: 12px;
}

/* Badge rentang PM / risiko */
.guide-popup-pm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 7px;
    font-size: 11.5px;
    font-weight: 600;
    font-family: 'DM Mono', 'Courier New', monospace;
    margin-bottom: 16px;
}

/* Skala warna dinamis */
.guide-scale-wrap      { margin-bottom: 18px; }
.guide-scale-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 9.5px;
    color: #9aa3bb;
    font-weight: 500;
    margin-bottom: 5px;
}
.guide-scale-bar {
    position: relative;
    height: 8px;
    border-radius: 99px;
    display: flex;
    gap: 2px;
    overflow: visible;
}

/* Segmen skala — dibangun via JS, aktif = opacity penuh */
.guide-scale-seg        { flex: 1; height: 100%; border-radius: 2px; opacity: 0.3; transition: opacity 0.2s; }
.guide-scale-seg.active { opacity: 1; }

/* Jarum — left & borderColor diatur via JS */
.guide-scale-needle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px; height: 14px;
    background: white;
    border-radius: 50%;
    border: 3px solid #ccc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition: left 0.4s cubic-bezier(0.34, 1.36, 0.64, 1);
    z-index: 2;
}

/* Grid Do's & Don'ts */
.guide-dd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.guide-dd-box  { border-radius: 11px; padding: 13px; border: 1.5px solid; }
.guide-dd-do   { background: #f0fdf4; border-color: #bbf7d0; }
.guide-dd-dont { background: #fef2f2; border-color: #fecaca; }

.guide-dd-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.07em;
    margin-bottom: 10px;
}
.guide-dd-do   .guide-dd-title   { color: #15803d; }
.guide-dd-dont .guide-dd-title   { color: #b91c1c; }
.guide-dd-do   .guide-dd-title i { color: #22c55e; }
.guide-dd-dont .guide-dd-title i { color: #ef4444; }

.guide-dd-item {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-bottom: 7px;
    font-size: 11.5px;
    line-height: 1.5;
}
.guide-dd-item:last-child { margin-bottom: 0; }

/* Bullet titik kecil */
.guide-dd-bullet {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}
.guide-dd-do   .guide-dd-bullet { background: #22c55e; }
.guide-dd-dont .guide-dd-bullet { background: #ef4444; }
.guide-dd-do   .guide-dd-item   { color: #166534; }
.guide-dd-dont .guide-dd-item   { color: #991b1b; }

/* Responsive: 1 kolom di layar kecil */
@media (max-width: 480px) {
    .guide-dd-grid     { grid-template-columns: 1fr; }
    .guide-popup-inner { padding: 16px 16px 20px; }
}