/* ------------------------------------------------ */
/* Global                                            */
/* ------------------------------------------------ */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Segoe UI, Arial, sans-serif;
    background: #eef3f8;
}

/* ------------------------------------------------ */
/* Header                                            */
/* ------------------------------------------------ */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 15px 30px;
    background: #004a87;
    color: white;

    position: relative;
}

/* Logos */
.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 50px;
    width: auto;
}

/* Titre centré */
.title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.title h1 {
    margin: 0;
}

.title p {
    margin: 5px 0 0 0;
}


/* ------------------------------------------------ */
/* Home page                                         */
/* ------------------------------------------------ */

.home_content {
    max-width: 1200px;
    margin: 40px auto;
    text-align: center;
    padding: 0 20px;
}

.cards {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 50px;
    flex-wrap: wrap;
}

.card {
    background: white;
    width: 100%;
    max-width: 350px;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0px 5px 20px rgba(0,0,0,0.15);
}

.card h3 {
    color: #0066aa;
}

.card button {
    background: #0066aa;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

.card button:hover {
    background: #004477;
}

footer {
    margin-top: 50px;
    text-align: center;
    color: #666;
}

/* ------------------------------------------------ */
/* Main content                                      */
/* ------------------------------------------------ */

/* --- Layout principal : map + graph côte à côte --- */

#content {
    display: flex;
    flex-direction: row;
    gap: 20px;
    padding: 20px;
    height: calc(100vh - 120px); /* header height */
    box-sizing: border-box;
}

/* Map panel à gauche */
#map_panel {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,.15);
    overflow: hidden;
}

/* Graph panel à droite */
#graph_panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,.15);
    overflow: hidden;
}

/* La carte doit avoir une hauteur fixe */
#map {
    flex: 1;
    min-height: 300px;
}

/* Plotly doit avoir une hauteur fixe */
#timeseries {
    flex: 1;
    min-height: 300px;
}

/* Leaflet fix */
.leaflet-container {
    width: 100%;
    height: 100%;
}

/* Responsive : en dessous de 900px, on empile */
@media (max-width: 900px) {
    #content {
        flex-direction: column;
        height: auto;
    }

    #map_panel,
    #graph_panel {
        flex: none;
        min-height: 350px;
    }
}


/* ------------------------------------------------ */
/* Station selector                                  */
/* ------------------------------------------------ */

#stat_selector,
#variable_selector {
    padding: 15px;
    background: #f7f9fc;
    border-bottom: 1px solid #d8d8d8;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

#stat_selector label,
#variable_selector label {
    font-weight: 600;
    color: #003b70;
}

/* ------------------------------------------------ */
/* Map                                               */
/* ------------------------------------------------ */

#map {
    flex: 1;
    padding: 10px;
}

.opacity_control {
    background: rgba(255,255,255,0.9);
    padding: 4px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.opacity_control input {
    width: 70px;
    margin: 0;
}

.opacity_control span {
    display: block;
    text-align: center;
    font-weight: bold;
}

/* ------------------------------------------------ */
/* Variable selector                                 */
/* ------------------------------------------------ */

#choose_var {
    width: 260px;
    max-width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #bbb;
    font-size: 15px;
}

/* ------------------------------------------------ */
/* Buttons                                           */
/* ------------------------------------------------ */

button {
    background: #005ea8;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    cursor: pointer;
    transition: .25s;
    font-weight: 600;
}

button:hover:not(:disabled) {
    background: #0076d6;
}

button:disabled {
    background: #bfc7d0;
    cursor: not-allowed;
}

#download_all,
#download_variable {
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
}

#download_all img,
#download_variable img {
    height: 16px;
}

/* ------------------------------------------------ */
/* Plot                                              */
/* ------------------------------------------------ */

#timeseries {
    flex: 1;
    padding: 10px;
}

#date_selector {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

#date_slider {
    width: 400px;
    max-width: 100%;
}

#date_display {
    font-weight: bold;
}

.map_legend {
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
    font-size: 12px;
}

.gradient {
    width: 150px;
    height: 15px;
    margin: 5px 0;
    background: linear-gradient(to right, rgb(255,255,255), rgb(255,0,0));
}
.gradient_custom {
    width: 120px;
    height: 12px;
    border: 1px solid #ccc;
    margin: 4px 0;
}

.legend_values {
    display: flex;
    justify-content: space-between;
}
.legend_item {
    display: flex;
    align-items: center;
    margin-bottom: 1px;   /* smaller spacing */
    font-size: 11px;      /* smaller text */
}
.legend_color {
    width: 12px;
    height: 12px;
    margin-right: 4px;
}

/* ------------------------------------------------ */
/* Responsive tweaks                                 */
/* ------------------------------------------------ */

@media (max-width: 600px) {
    header {
        text-align: center;
        justify-content: center;
    }

    .title {
        margin-top: 10px;
    }

    #content {
        padding: 10px;
    }

    .cards {
        gap: 20px;
    }
}
#map_panel,
#graph_panel {
    min-height: 400px;
}

#map {
    height: 100%;
    min-height: 300px;
}

#timeseries {
    min-height: 300px;
}
.leaflet-container {
    width: 100%;
    height: 100%;
    min-height: 300px;
}
@media (max-width: 600px) {
    #map_panel,
    #graph_panel {
        min-height: 350px;
    }

    #map,
    #timeseries {
        min-height: 250px;
    }
}
