/* --- THÈME & VARIABLES --- */
:root {
    /* Couleurs Principales */
    --color-primary: #00287a;
    --color-secondary: #ffc72c;
    --color-text-light: #f4f4f4;
    --color-text-dark: #333;
    --color-bg-dark: #12122b;
    
    /* Couleurs d'État (Wait Times) */
    --color-green: #28a745;
    --color-green-dark: #198754;
    --color-orange: #fd7e14; /* Unifié avec JS */
    --color-yellow: #ffc107;
    --color-red: #dc3545;
    --color-blue-info: #0d6fdc;
    
    /* Popup Styles */
    --popup-bg: #fcfcfc;
    --popup-text: #333;
    --popup-border: #0056b3;
    
    /* Layout */
    --header-height: 66px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 15px;
    --radius-md: 4px;
    --radius-lg: 6px;
    
    /* Ombres */
    --shadow-control: 0 1px 5px rgba(0,0,0,0.65);
    --shadow-popup: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-btn: 0 4px 8px rgba(0,0,0,0.6);
}

/* --- BASE --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
    background-color: var(--color-bg-dark);
    color: var(--color-text-light);
}

/* --- CARTE --- */
#map {
    height: calc(100vh - var(--header-height));
    width: 100%;
    z-index: 1;
}

/* --- HEADER --- */
.park-header {
    background-color: var(--color-primary);
    padding: var(--spacing-lg);
    border-bottom: 3px solid var(--color-secondary);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    height: var(--header-height);
    box-sizing: border-box; /* Important pour le calcul de hauteur */
}

.park-header h1 {
    font-family: 'Poppins', sans-serif;
    font-size: 2em;
    color: var(--color-secondary);
    margin: 0;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    font-weight: 700;
    line-height: 1.2;
}

.back-link {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5em;
    color: var(--color-secondary);
    text-decoration: none;
    line-height: 1;
    font-weight: 700;
}

/* --- LEAFLET CONTROLS & FILTRES --- */

/* Style commun pour les contrôles personnalisés */
.leaflet-control-custom a {
    background-color: white;
    cursor: pointer;
    padding: 5px 8px;
    line-height: 30px;
    display: block;
    border-radius: var(--radius-md);
    color: var(--color-primary);
    font-weight: bold;
    text-decoration: none;
    text-align: center;
}

/* Conteneur des filtres (Desktop par défaut) */
.leaflet-control-custom.filter-controls {
    border-radius: var(--radius-md);
    z-index: 1000;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: white;
    box-shadow: var(--shadow-control);
    margin-top: 10px; /* Marge top pour éviter le header */
    
    display: flex;
    flex-direction: row;
    gap: 10px;
    width: auto;
}

/* Boutons individuels dans le filtre */
.filter-button {
    cursor: pointer;
    padding: 6px 10px;
    border: 1px solid #ccc;
    background-color: #f8f9fa;
    color: var(--color-text-dark);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: background-color 0.2s, color 0.2s;
    text-align: center;
    width: auto;
}

.filter-button.active {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Bouton toggle Mobile (engrenage) */
.filter-toggle-button {
    display: none; /* Caché sur desktop */
    position: fixed; 
    bottom: 15px;
    right: 15px;
    z-index: 1010; 
}

.filter-toggle-button button {
    background-color: var(--color-primary);
    color: var(--color-secondary);
    border: none;
    padding: 10px 14px; 
    border-radius: 50%;
    font-size: 1.3em;
    cursor: pointer;
    box-shadow: var(--shadow-btn);
    line-height: 1;
    transition: background-color 0.2s;
}

/* --- POPUPS LEAFLET --- */

.leaflet-popup-content-wrapper {
    background: var(--popup-bg);
    color: var(--popup-text);
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow-popup);
    border: 1px solid var(--popup-border);
}

.leaflet-popup-tip {
    background-color: var(--popup-bg);
    border: 1px solid var(--popup-border);
    border-left-color: transparent;
    border-top-color: transparent;
    box-shadow: none;
}

.map-popup {
    padding: 12px 15px;
    max-width: 250px;
    text-align: left;
}

.map-popup h4 {
    color: var(--color-primary);
    font-size: 1.1em;
    font-weight: 600;
    margin: 0 0 8px 0;
    border-bottom: 1px solid var(--popup-border);
    padding-bottom: 5px;
}

.map-popup p {
    font-size: 0.88em;
    line-height: 1.4;
    margin-bottom: 8px;
}

.map-popup strong {
    color: var(--color-primary);
    font-weight: 700;
}

.leaflet-popup-close-button {
    color: var(--color-primary) !important;
    font-size: 1.4em !important;
    right: 8px !important;
    top: 8px !important;
}

/* --- TOOLTIPS (Bulles de temps d'attente) --- */

.wait-time-tooltip {
    font-weight: 700;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: var(--radius-md);
    border: none;
    opacity: 0.95;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    white-space: nowrap;
    line-height: 1;
    min-width: 40px;
    text-align: center;
}

/* Couleurs dynamiques basées sur le JS */
/* Note: les classes sont générées comme wait-time-tooltip-[HEX] */
.wait-time-tooltip-198754 { background-color: var(--color-green-dark); color: white; }
.wait-time-tooltip-28a745 { background-color: var(--color-green); color: white; }
.wait-time-tooltip-ffc107 { background-color: var(--color-yellow); color: black; }
.wait-time-tooltip-fd7e14 { background-color: var(--color-orange); color: white; }
.wait-time-tooltip-dc3545 { background-color: var(--color-red); color: white; }
.wait-time-tooltip-0d6fdc { background-color: var(--color-blue-info); color: white; }


/* ============================== */
/* ⭐ RESPONSIVE (Mobile First Logic) ⭐ */
/* ============================== */

/* Mobile (< 600px) */
@media (max-width: 599px) {
    /* Transformation du menu de filtres en overlay mobile */
    .leaflet-control-custom.filter-controls {
        display: none !important; /* Caché par défaut */
        flex-direction: column; 
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto !important;
        width: 100%;
        max-height: 50vh;
        overflow-y: auto;
        border-radius: 10px 10px 0 0;
        padding: 15px;
        margin: 0; /* Reset marge desktop */
        z-index: 1009;
    }
    
    /* Classe ajoutée par JS pour afficher l'overlay */
    .filter-controls.visible {
        display: flex !important;
    }

    .filter-button {
        width: 100%;
        padding: 10px; /* Plus facile à toucher */
        font-size: 16px;
    }

    .filter-toggle-button {
        display: block;
    }
}

/* Desktop (>= 600px) */
@media (min-width: 600px) {
    /* Retour au layout horizontal en haut à droite */
    .leaflet-control-custom.filter-controls {
        display: flex !important; 
        flex-direction: row;
        width: auto;
    }
    
    .filter-toggle-button {
        display: none;
    }
}