/* ==========================================================================
   1. DESIGN SYSTEM & CSS VARIABLES (:root)
   ========================================================================== */
:root {
    /* Core UI Colors */
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.08);
    --success: #10b981;
    --success-border: rgba(16, 185, 129, 0.3);
    --warning: #f59e0b;
    --warning-border: rgba(245, 158, 11, 0.3);
    --danger: #ef4444;
    --danger-border: rgba(239, 68, 68, 0.45);
    
    /* Typography & Neutral Colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #64748b;
    --bg-darker: #030712;
    --bg-card: #111827;
    
    /* Premium Glassmorphism Gradients */
    --glass-bg: linear-gradient(145deg, rgba(17, 24, 39, 0.65), rgba(30, 41, 59, 0.45));
    --glass-hover-bg: linear-gradient(145deg, rgba(17, 24, 39, 0.75), rgba(30, 41, 59, 0.55));
    --glass-border: rgba(255, 255, 255, 0.06);
}

/* ==========================================================================
   2. RESET & BASE STYLES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-main);
    background-size: 200% 200%;
    animation: bgMove 25s ease infinite;
    transition: background 1.5s ease;
}

body.theme-loading { background: var(--bg-darker); }
body.theme-aman { background: radial-gradient(circle at top right, #022c22, var(--bg-darker)); }
body.theme-waspada { background: radial-gradient(circle at top right, #451a03, var(--bg-darker)); }
body.theme-bahaya { background: radial-gradient(circle at top right, #450a0a, var(--bg-darker)); }

@keyframes bgMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    width: 95%;
    max-width: 1200px;
    margin: auto;
    padding: 40px 20px;
}

/* ==========================================================================
   3. INFRASTRUCTURE COMPONENTS (Loading, Toast, & Header)
   ========================================================================== */
.loading-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-darker);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.spinner {
    width: 50px; height: 50px;
    border: 5px solid rgba(56, 189, 248, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}
@keyframes spin { to { transform: rotate(360deg); } }

header { text-align: center; margin-bottom: 40px; }
header h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--text-main);
    margin-bottom: 8px;
}
.badge-v2 {
    font-size: 0.9rem; background: var(--primary); color: var(--bg-darker);
    padding: 2px 10px; border-radius: 8px; vertical-align: middle;
}
header p { color: var(--text-muted); font-size: 0.95rem; font-weight: 500; }

.live-clock {
    margin-top: 12px; font-size: 0.9rem; color: var(--primary);
    background: var(--primary-glow); padding: 6px 18px;
    border-radius: 30px; display: inline-block; border: 1px solid rgba(56, 189, 248, 0.15);
}

.toast-container { position: fixed; top: 24px; right: 24px; z-index: 10005; }
.toast {
    background: var(--bg-darker); color: var(--text-main); padding: 16px 24px; border-radius: 16px; margin-bottom: 10px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5); display: flex; align-items: center; gap: 12px;
    transform: translateX(130%); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show { transform: translateX(0); }

/* ==========================================================================
   4. LAYOUT GRID & GLASSMORPHISM CARDS
   ========================================================================== */
.top-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px; margin-bottom: 40px;
}
.main-content-grid {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 24px; margin-bottom: 40px;
}
@media (max-width: 968px) {
    .main-content-grid { grid-template-columns: 1fr; }
}

/* Glassmorphism Premium Cards (Gradasi 145deg & Dioptimasi Efisiensi Transition) */
.status-card, .card, .chart-card, .system, .gauge-card, .meta-card, .stats-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px; padding: 26px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    /* Optimasi Performa: Menghindari properti 'all' */
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), 
                box-shadow 0.4s ease, 
                border-color 0.4s ease, 
                background 0.4s ease;
}

/* Global Hover Lift Effect (Lebih Premium & Hemat Performa) */
.status-card:hover,
.chart-card:hover,
.gauge-card:hover,
.meta-card:hover,
.stats-card:hover,
.card:hover,
.system:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45), 0 0 20px var(--primary-glow);
    background: var(--glass-hover-bg);
}

.status-card h2, .gauge-card h2, .meta-card h2, .chart-card h2, .stats-card h2, .system h2 {
    font-size: 1rem; color: var(--text-muted); margin-bottom: 18px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}

/* ==========================================================================
   5. METRICS & CUSTOM MONITORING CONTROLS
   ========================================================================== */
.status {
    font-size: 1.6rem; font-weight: 800; padding: 25px;
    border-radius: 16px; display: flex; align-items: center; justify-content: center; gap: 12px;
}
.aman { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid var(--success-border); }
.waspada { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid var(--warning-border); }

/* Efek Bahaya: Diturunkan Menjadi 0.8s Agar Lebih Ramah Mata & Filter Drop Shadow Lebih Realistis */
.bahaya { 
    background: rgba(239, 68, 68, 0.2); 
    color: var(--danger); 
    border: 1px solid var(--danger-border);
    animation: pulse-danger 1.5s infinite alternate, dangerShake 0.8s infinite;
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.2));
}

@keyframes pulse-danger {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    100% { box-shadow: 0 0 25px 8px rgba(239, 68, 68, 0.1); }
}

@keyframes dangerShake {
    0% { transform: translateX(0); }
    25% { transform: translateX(1px); }
    50% { transform: translateX(-1px); }
    75% { transform: translateX(1px); }
    100% { transform: translateX(0); }
}

/* Gauge Meter Engine (Menggunakan Drop-Shadow & Variabel) */
.gauge-wrapper { display: flex; justify-content: center; margin-top: 10px; }
.gauge-body {
    position: relative; width: 180px; height: 90px;
    background: rgba(255,255,255,0.05);
    border-radius: 100px 100px 0 0; overflow: hidden;
}

.gauge-fill {
    position: absolute; top: 100%; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to right, var(--success), var(--warning), var(--danger));
    transform-origin: center top;
    transform: rotate(0deg);
    transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.2)); /* Menggunakan drop-shadow sesuai saranmu */
}

.gauge-cover {
    position: absolute; width: 140px; height: 70px;
    background: rgba(17, 24, 39, 1); border-radius: 80px 80px 0 0;
    bottom: 0; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 6px;
}
.gauge-cover span { font-size: 1.8rem; font-weight: 800; color: var(--text-main); line-height: 1; }
.gauge-cover p { font-size: 0.75rem; color: var(--text-dark); font-weight: bold; }
.gauge-scale { display: flex; justify-content: space-between; padding: 5px 15px 0 15px; font-size: 0.75rem; color: var(--text-dark); font-weight: 600; }

.meta-item { display: flex; align-items: center; gap: 15px; margin-bottom: 16px; }
.meta-item:last-child { margin-bottom: 0; }
.meta-icon { font-size: 1.5rem; color: var(--primary); width: 40px; height: 40px; background: var(--primary-glow); border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.meta-label { font-size: 0.8rem; color: var(--text-dark); font-weight: 600; }

/* ==========================================================================
   6. METRIC CARDS GRID & MINI STATISTICS PANEL
   ========================================================================== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 24px; margin-bottom: 40px; }
.card { text-align: center; }
.card-icon { font-size: 2.2rem; margin-bottom: 12px; }
.card h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; }
.card h1 { font-size: 3rem; font-weight: 800; color: var(--text-main); }
.card .unit { font-size: 0.8rem; color: var(--text-dark); margin-top: 4px; }

.card-status-aman { border-left: 6px solid var(--success); }
.card-status-waspada { border-left: 6px solid var(--warning); }
.card-status-bahaya { border-left: 6px solid var(--danger); }

/* Elastis Pop-Up Saat Data Update */
.value-pop {
    animation: valuePopEffect 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes valuePopEffect {
    0% { transform: scale(1); }
    50% { transform: scale(1.06); color: var(--primary); }
    100% { transform: scale(1); }
}

/* Chart Container */
.chart-container { position: relative; width: 100%; height: 350px; }

/* Mini Statistics Panel */
.stat-box {
    background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04);
    padding: 14px; border-radius: 14px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center;
}
.stat-box:last-child { margin-bottom: 0; }
.stat-title { font-size: 0.8rem; text-transform: uppercase; color: var(--text-dark); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.stat-box h2 { font-size: 1.5rem; font-weight: 800; color: #f1f5f9; }

/* ==========================================================================
   7. SYSTEM DETAILS & FOOTER BRANDING
   ========================================================================== */
.system-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; font-size: 0.9rem; }
.online { color: #34d399; font-weight: 600; }
.offline { color: var(--danger); font-weight: 600; }

footer { margin-top: 50px; text-align: center; color: var(--text-dark); font-size: 0.85rem; line-height: 1.6; }
.footer-sub {
    font-size: 0.8rem;
    color: var(--text-dark);
    margin-top: 4px;
    display: inline-block;
}