/* =========================================================
   BASE
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: #f5f7fa;
    color: #1f2937;
}


/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
    background: white;

    border-bottom: 1px solid #e5e7eb;

    padding: 20px 30px;

    display: flex;

    justify-content: space-between;
    align-items: center;

    position: sticky;
    top: 0;

    z-index: 10;
}

.topbar h1 {
    margin: 0;

    font-size: 1.5rem;
}

.subtitle {
    margin: 3px 0 0;

    color: #6b7280;

    font-size: 0.9rem;
}


/* =========================================================
   STATUS
   ========================================================= */

.status {
    display: flex;

    align-items: center;

    gap: 8px;

    font-size: 0.85rem;

    color: #6b7280;
}

#status-dot {
    width: 9px;
    height: 9px;

    border-radius: 50%;

    background: #9ca3af;
}

#status-dot.online {
    background: #22c55e;
}

#status-dot.offline {
    background: #ef4444;
}


/* =========================================================
   CONTAINER
   ========================================================= */

.container {
    max-width: 1200px;

    margin: 0 auto;

    padding: 30px 20px 60px;
}


/* =========================================================
   SECTIONS
   ========================================================= */

section {
    margin-bottom: 30px;
}

.section-title {
    display: flex;

    justify-content: space-between;
    align-items: center;

    margin-bottom: 15px;
}

.section-title h2 {
    margin: 0;

    font-size: 1.2rem;
}

.section-title p {
    margin: 4px 0 0;

    color: #6b7280;

    font-size: 0.85rem;
}


/* =========================================================
   CAPTEURS
   ========================================================= */

.sensor-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(210px, 1fr));

    gap: 15px;
}

.sensor-card {
    background: white;

    border: 1px solid #e5e7eb;

    border-radius: 14px;

    padding: 20px;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.04);
}

.sensor-card h3 {
    margin: 0 0 15px;

    font-size: 1rem;
}

.sensor-values {
    display: flex;

    gap: 20px;
}

.sensor-value {
    flex: 1;
}

.sensor-value .number {
    display: block;

    font-size: 1.8rem;

    font-weight: 700;
}

.sensor-value .label {
    color: #6b7280;

    font-size: 0.75rem;

    margin-top: 2px;
}

.sensor-date {
    margin-top: 15px;

    color: #9ca3af;

    font-size: 0.75rem;
}


/* =========================================================
   CONTROLES
   ========================================================= */

.controls-section {
    background: white;

    border: 1px solid #e5e7eb;

    border-radius: 14px;

    padding: 20px;

    display: flex;

    flex-wrap: wrap;

    gap: 25px;

    align-items: end;
}

.control-group {
    display: flex;

    flex-direction: column;

    gap: 8px;
}

.control-group label {
    font-size: 0.8rem;

    font-weight: 600;

    color: #4b5563;
}

select {
    min-width: 220px;

    padding: 10px 12px;

    border-radius: 8px;

    border: 1px solid #d1d5db;

    background: white;

    font-size: 0.95rem;
}

.period-buttons {
    display: flex;

    flex-wrap: wrap;

    gap: 6px;
}

.period-button {
    border: 1px solid #d1d5db;

    background: white;

    padding: 9px 14px;

    border-radius: 8px;

    cursor: pointer;

    font-size: 0.85rem;
}

.period-button:hover {
    background: #f3f4f6;
}

.period-button.active {
    background: #111827;

    color: white;

    border-color: #111827;
}


/* =========================================================
   BUTTON
   ========================================================= */

.secondary-button {
    border: 1px solid #d1d5db;

    background: white;

    padding: 9px 14px;

    border-radius: 8px;

    cursor: pointer;

    font-size: 0.85rem;
}

.secondary-button:hover {
    background: #f3f4f6;
}


/* =========================================================
   GRAPHIQUES
   ========================================================= */

.chart-section {
    background: white;

    border: 1px solid #e5e7eb;

    border-radius: 14px;

    padding: 20px;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.03);
}

.chart-container {
    position: relative;

    width: 100%;

    height: 380px;
}


/* =========================================================
   CHARGEMENT
   ========================================================= */

.loading {
    background: white;

    border: 1px solid #e5e7eb;

    border-radius: 14px;

    padding: 30px;

    text-align: center;

    color: #6b7280;
}


/* =========================================================
   ERREUR
   ========================================================= */

.error-message {
    background: #fef2f2;

    color: #991b1b;

    border: 1px solid #fecaca;

    border-radius: 10px;

    padding: 15px;

    margin-top: 20px;

    white-space: pre-wrap;
}

.hidden {
    display: none;
}


/* =========================================================
   FOOTER
   ========================================================= */

footer {
    border-top: 1px solid #e5e7eb;

    background: white;

    color: #9ca3af;

    padding: 20px;

    font-size: 0.75rem;

    display: flex;

    justify-content: space-between;

    gap: 20px;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .topbar {
        padding: 15px 18px;
    }

    .container {
        padding: 20px 12px 40px;
    }

    .section-title {
        align-items: flex-start;

        gap: 15px;
    }

    .sensor-grid {
        grid-template-columns: 1fr;
    }

    .controls-section {
        flex-direction: column;

        align-items: stretch;
    }

    select {
        width: 100%;
    }

    .period-buttons {
        width: 100%;
    }

    .period-button {
        flex: 1;
    }

    .chart-container {
        height: 280px;
    }

    footer {
        flex-direction: column;
    }
}