/* Styles pour la carte interactive de la Mauritanie */

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #eef0f2;
    color: #333;
    line-height: 1.6;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* S'assurer que le conteneur prend au moins toute la hauteur de la vue */
    max-width: 1400px;
    margin: 0 auto;
    background-color: #fff;
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
}

header {
    text-align: center;
    padding: 20px 15px;
    background-color: #4a69bd; /* Bleu thématique */
    color: white;
    border-bottom: 4px solid #3b5998;
}

header h1 {
    margin: 0;
    font-size: 2em;
}

header p {
    margin: 5px 0 0;
    font-size: 1em;
    opacity: 0.9;
}

main {
    display: flex;
    flex: 1; /* Permet à main de grandir pour remplir l'espace vertical */
    gap: 20px;
    padding: 20px;
    overflow: hidden; /* Empêcher le débordement de main */
}

#map-container {
    flex: 3; /* Donner plus d'espace à la carte par défaut */
    position: relative;
    display: flex; /* Pour que la carte à l'intérieur puisse prendre 100% de hauteur */
    flex-direction: column;
}

#map {
    height: 100%; 
    min-height: 500px; /* Hauteur minimale pour desktop */
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-grow: 1; /* S'assurer que la carte remplit l'espace de map-container */
}

#info-container {
    flex: 1.5; /* Espace pour le panneau d'info */
    overflow-y: auto;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

#info-panel {
    height: 100%;
}

#info-panel h2 {
    margin-top: 0;
    color: #4a69bd;
    border-bottom: 2px solid #4a69bd;
    padding-bottom: 10px;
    font-size: 1.4em;
}

#info-panel h3 {
    color: #333;
    margin-top: 20px;
    font-size: 1.2em;
}

#info-panel p {
    font-size: 0.95em;
    margin-bottom: 8px;
}

.chart-container {
    height: 220px; /* Légèrement plus grand pour une meilleure lisibilité */
    margin: 20px 0;
    background-color: #fff;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.info.legend {
    background: rgba(255,255,255,0.9);
    padding: 10px 15px;
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
    font-size: 0.9em;
}

.info.legend h4 {
    margin: 0 0 8px;
    font-size: 1.1em;
    color: #333;
}

.info.legend i {
    width: 18px;
    height: 18px;
    float: left;
    margin-right: 8px;
    border: 1px solid #ccc;
}

.region-tooltip {
    background: rgba(255,255,255,0.9);
    border: 1px solid #ccc;
    box-shadow: 0 1px 5px rgba(0,0,0,0.15);
    border-radius: 4px;
    padding: 6px 10px;
    font-weight: bold;
    color: #333;
}

footer {
    text-align: center;
    padding: 15px;
    color: #555;
    font-size: 0.85em;
    background-color: #f1f1f1;
    border-top: 1px solid #ddd;
}

/* Styles pour les contrôles de données (sélecteurs, bouton bascule) */
.data-controls {
    background: white;
    padding: 8px;
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
}

.data-controls select, .data-controls button {
    margin: 4px;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
}

.data-controls button.toggle-button {
    background-color: #5cb85c;
    color: white;
    cursor: pointer;
}

.data-controls button.toggle-button:hover {
    background-color: #4cae4c;
}

.action-button {
    background-color: #4a69bd;
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin-top: 10px;
}

.action-button:hover {
    background-color: #3b5998;
}

/* Styles pour le panneau du calculateur */
.calculator-panel {
    position: fixed; /* Ou absolute par rapport à un conteneur parent */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    z-index: 1001; /* Au-dessus de la carte et des contrôles Leaflet */
    display: none; /* Caché par défaut */
    max-height: 80vh;
    overflow-y: auto;
}

.calculator-panel h2 {
    margin-top: 0;
    color: #4a69bd;
    text-align: center;
}

.calculator-panel .tabs button {
    padding: 10px 15px;
    cursor: pointer;
    border: 1px solid #ddd;
    background: #f0f0f0;
    margin-right: 5px;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.calculator-panel .tabs button.active {
    background: white;
    border-bottom: 1px solid white;
}

.calculator-panel .tab-content {
    border: 1px solid #ddd;
    padding: 15px;
    border-top: none;
}

.calculator-panel label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
}

.calculator-panel input[type="number"], .calculator-panel input[type="text"] {
    width: calc(100% - 22px); /* Ajuster pour padding et bordure */
    padding: 8px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.calculator-panel .results-section p {
    margin: 5px 0;
}

.calculator-panel .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
}

/* Styles responsives */
#mobile-info-toggle {
    display: none; /* Caché par défaut sur desktop */
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000; /* Au-dessus de la carte */
    padding: 10px 20px;
    background-color: #4a69bd;
    color: white;
    border: none;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    font-size: 1em;
    cursor: pointer;
}

@media (max-width: 768px) {
    .container {
        padding: 0; /* Pas de padding sur le conteneur principal pour mobile */
    }

    header {
        padding: 15px;
        border-bottom-width: 3px;
    }
    header h1 {
        font-size: 1.5em;
    }
    header p {
        font-size: 0.9em;
    }

    main {
        flex-direction: column;
        padding: 10px; /* Réduire le padding de main */
        gap: 10px;
    }

    #map-container {
        height: 50vh; /* Hauteur fixe pour la carte sur mobile */
        min-height: 280px; /* Assurer une hauteur minimale même sur petits écrans */
    }
    
    #map {
        min-height: 0; /* Annuler le min-height desktop */
    }

    #info-container {
        height: calc(50vh - 70px); /* Ajuster en fonction de la hauteur de la carte et du header/footer/bouton */
        /* Ou utiliser flex-grow: 1; si la hauteur de main est bien gérée */
        margin-top: 0; /* Pas de marge en haut, le gap s'en charge */
        padding: 10px;
        /* Par défaut, le panneau d'info est visible */
    }

    #info-container.hidden-mobile {
        display: none;
    }

    #mobile-info-toggle {
        display: block; /* Afficher le bouton sur mobile */
    }

    /* Ajuster la taille de la légende sur mobile */
    .info.legend {
        font-size: 0.8em;
        padding: 8px;
    }
    .info.legend h4 {
        font-size: 1em;
    }

    /* Ajuster les contrôles de données sur mobile */
    .data-controls {
        padding: 5px;
    }
    .data-controls select, .data-controls button {
        padding: 5px 8px;
        font-size: 0.85em;
        margin: 2px;
    }

    footer {
        padding: 10px;
        font-size: 0.8em;
    }

    .calculator-panel {
        width: 95%;
        max-height: 85vh;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.3em;
    }
    header p {
        font-size: 0.8em;
    }

    #map-container {
        height: 45vh;
    }

    #info-container {
        height: calc(55vh - 60px); /* Plus d'espace pour l'info si la carte est plus petite */
    }

    #mobile-info-toggle {
        font-size: 0.9em;
        padding: 8px 15px;
    }

    .chart-container {
        height: 180px;
    }
}

