/* ============================================
   GoIoT Dashboard - Air Quality Monitoring
   Theme: Blue Gradient Professional
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-start: #0f172a;
    --primary-mid:   #1e3a5f;
    --primary-end:   #1d4ed8;
    --accent:        #38bdf8;
    --accent-glow:   rgba(56, 189, 248, 0.3);
    --card-bg:       rgba(255, 255, 255, 0.05);
    --card-border:   rgba(255, 255, 255, 0.1);
    --text-primary:  #f0f9ff;
    --text-secondary:#94a3b8;
    --good:          #22c55e;
    --medium:        #f59e0b;
    --bad:           #ef4444;
    --radius:        16px;
    --shadow:        0 8px 32px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-mid) 50%, #0c2461 100%);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

/* ---- Header ---- */
.header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--card-border);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--primary-end));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 0 20px var(--accent-glow);
}

.logo-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.logo-text span {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--good);
    animation: pulse 2s infinite;
}

.dot.offline { background: var(--bad); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

#last-update {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ---- Main Layout ---- */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* ---- Section Title ---- */
.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

/* ---- Stat Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--primary-end));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.stat-icon.blue   { background: rgba(56, 189, 248, 0.15); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.15); }
.stat-icon.green  { background: rgba(34, 197, 94, 0.15); }
.stat-icon.purple { background: rgba(168, 85, 247, 0.15); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-unit {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ---- Status Badge ---- */
.quality-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 8px;
}

.quality-badge.baik   { background: rgba(34, 197, 94, 0.15); color: var(--good); border: 1px solid rgba(34, 197, 94, 0.3); }
.quality-badge.sedang { background: rgba(245, 158, 11, 0.15); color: var(--medium); border: 1px solid rgba(245, 158, 11, 0.3); }
.quality-badge.buruk  { background: rgba(239, 68, 68, 0.15); color: var(--bad); border: 1px solid rgba(239, 68, 68, 0.3); }

/* ---- Charts Grid ---- */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.chart-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-card-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chart-wrapper {
    position: relative;
    height: 260px;
}

/* ---- Donut Chart ---- */
.donut-wrapper {
    position: relative;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.legend-label {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    flex: 1;
}

.legend-count {
    color: var(--text-primary);
    font-weight: 600;
}

/* ---- Table ---- */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.table-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 0.75rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--card-border);
}

tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}

tbody tr:hover { background: rgba(255,255,255,0.04); }
tbody tr:last-child { border-bottom: none; }

tbody td {
    padding: 0.85rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.baik   { background: rgba(34, 197, 94, 0.15); color: var(--good); }
.badge.sedang { background: rgba(245, 158, 11, 0.15); color: var(--medium); }
.badge.buruk  { background: rgba(239, 68, 68, 0.15); color: var(--bad); }

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--card-border);
}

/* ---- Loading Skeleton ---- */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    height: 20px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .main { padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .header-inner { padding: 0; }
    .logo-text h1 { font-size: 0.9rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
