/* ============================================
   FONT & RESET
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.app {
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

/* ============================================
   HEADER
   ============================================ */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 25px 20px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #ffffff, #a8b5e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 14px;
    opacity: 0.7;
    margin-top: 5px;
    letter-spacing: 2px;
    color: #c8d0e6;
}

/* ============================================
   STATUS CARD
   ============================================ */
.status-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

.status-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.status-card.aman {
    border-left-color: #27ae60;
    background: linear-gradient(135deg, #ffffff, #f0fff4);
}

.status-card.waspada {
    border-left-color: #f39c12;
    background: linear-gradient(135deg, #ffffff, #fffbeb);
}

.status-card.bahaya {
    border-left-color: #e74c3c;
    background: linear-gradient(135deg, #ffffff, #fdf0ed);
}

.status-card.tidak-hujan {
    border-left-color: #94a3b8;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
}

.status-indicator {
    margin-bottom: 15px;
}

.status-icon {
    font-size: 64px;
    display: block;
}

.status-text {
    font-size: 32px;
    font-weight: 700;
    margin-top: 5px;
}

.status-card.aman .status-text { color: #27ae60; }
.status-card.waspada .status-text { color: #f39c12; }
.status-card.bahaya .status-text { color: #e74c3c; }
.status-card.tidak-hujan .status-text { color: #64748b; }

.score-container {
    margin: 15px 0;
}

.score-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.score-value {
    font-size: 56px;
    font-weight: 700;
    display: inline-block;
}

.status-card.aman .score-value { color: #27ae60; }
.status-card.waspada .score-value { color: #f39c12; }
.status-card.bahaya .score-value { color: #e74c3c; }
.status-card.tidak-hujan .score-value { color: #94a3b8; }

.score-max {
    font-size: 20px;
    color: #999;
    display: inline-block;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.status-card.aman .progress-fill { background: linear-gradient(90deg, #27ae60, #2ecc71); }
.status-card.waspada .progress-fill { background: linear-gradient(90deg, #f39c12, #f1c40f); }
.status-card.bahaya .progress-fill { background: linear-gradient(90deg, #e74c3c, #c0392b); }
.status-card.tidak-hujan .progress-fill { background: #94a3b8; }

.timestamp {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
}

/* ============================================
   SENSORS GRID
   ============================================ */
.sensors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.sensor-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

.sensor-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.sensor-label {
    font-size: 14px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.sensor-value {
    font-size: 40px;
    font-weight: 700;
    color: #2a5298;
}

.sensor-unit {
    font-size: 14px;
    color: #999;
    margin-bottom: 10px;
}

.sensor-category {
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 20px;
    display: inline-block;
    background: #e8ecf1;
    color: #333;
    font-weight: 600;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #2a5298;
}

.stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   CHART
   ============================================ */
.chart-container {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.chart-header h3 {
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.btn-chart {
    padding: 8px 20px;
    background: #2a5298;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-chart:hover {
    background: #1e3c72;
}

.chart-wrapper {
    width: 100%;
    position: relative;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 350px;
}

/* ============================================
   TABLES
   ============================================ */
.rekap-container,
.history-container {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.rekap-container h3,
.history-container h3 {
    margin-bottom: 20px;
    color: #333;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 1px;
    border-bottom: 2px solid #e8ecf1;
    padding-bottom: 12px;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #e8ecf1;
}

th {
    background: #f1f4f9;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 14px 16px;
    text-align: center;
    border-bottom: 2px solid #e0e4ea;
}

tr:hover {
    background: #f8fafc;
}

/* Status di Tabel - Badge Style */
td .status-aman,
td .status-waspada,
td .status-bahaya {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

td .status-aman {
    background: #d4edda;
    color: #155724;
}

td .status-waspada {
    background: #fff3cd;
    color: #856404;
}

td .status-bahaya {
    background: #f8d7da;
    color: #721c24;
}

/* Fallback */
.status-aman { color: #27ae60; font-weight: 700; }
.status-waspada { color: #f39c12; font-weight: 700; }
.status-bahaya { color: #e74c3c; font-weight: 700; }

.loading {
    text-align: center;
    color: #94a3b8;
    padding: 30px;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    letter-spacing: 0.5px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    header h1 {
        font-size: 24px;
    }
    
    .status-text {
        font-size: 24px;
    }
    
    .score-value {
        font-size: 40px;
    }
    
    .sensor-value {
        font-size: 30px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-wrapper canvas {
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 18px;
    }
    
    .status-icon {
        font-size: 48px;
    }
    
    .status-text {
        font-size: 20px;
    }
    
    .score-value {
        font-size: 32px;
    }
    
    .sensors-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-wrapper canvas {
        max-height: 200px;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 8px 10px;
    }
}