/**
 * Description du fichier : EtudeSol.fr - Styles spécifiques à la carte interactive Leaflet
 * Nom du fichier : assets/css/carte.css
 * Version du fichier : 1.0 avec fonctionnalités avancées et intégration BRGM
 * @author Philippe MAUXION
 * Editeur : SPM Conseil
 * Copyright 2025
 * Date de création du fichier : 04/01/2025
 * Date de création du fichier : 31/08/2025
 * Date de modification du fichier : 31/08/2025
 */

/* ===========================================
   CONTENEUR PRINCIPAL DE LA CARTE
   =========================================== */

.carte-container {
    height: 500px;
    width: 100%;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    position: relative;
    background: #f8f9fa;
}

/* Responsive de la carte */
@media (max-width: 767.98px) {
    .carte-container {
        height: 400px;
        border-radius: 10px;
    }
}

@media (min-width: 1200px) {
    .carte-container {
        height: 600px;
    }
}

/* ===========================================
   PERSONNALISATION LEAFLET
   =========================================== */

/* Contrôles de zoom personnalisés */
.leaflet-control-zoom {
    border-radius: 10px !important;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1) !important;
    border: none !important;
}

.leaflet-control-zoom a {
    background: white !important;
    color: #0d6efd !important;
    border: none !important;
    font-weight: bold !important;
    transition: all 0.2s ease !important;
}

.leaflet-control-zoom a:hover {
    background: #0d6efd !important;
    color: white !important;
    transform: scale(1.05);
}

/* Attribution personnalisée */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 5px !important;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
}

/* ===========================================
   MARQUEURS PERSONNALISÉS
   =========================================== */

/* Marqueur de position utilisateur */
.marqueur-utilisateur {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0d6efd;
    border: 3px solid white;
    box-shadow: 0 0 10px rgba(13, 110, 253, 0.5);
    animation: pulse-user 2s infinite;
}

@keyframes pulse-user {
    0% {
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(13, 110, 253, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0);
    }
}

/* Marqueurs d'aléa géologique */
.marqueur-alea {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.75rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.marqueur-alea:hover {
    transform: scale(1.2);
    z-index: 1000;
}

.marqueur-alea-fort {
    background: #dc3545;
}

.marqueur-alea-moyen {
    background: #ffc107;
    color: #212529;
}

.marqueur-alea-faible {
    background: #198754;
}

.marqueur-alea-indetermine {
    background: #6c757d;
}

/* ===========================================
   POPUPS ET TOOLTIPS CARTE
   =========================================== */

/* Popup Leaflet personnalisée */
.leaflet-popup-content-wrapper {
    border-radius: 10px !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    border: none !important;
}

.leaflet-popup-content {
    margin: 1rem !important;
    font-family: 'Inter', sans-serif !important;
    line-height: 1.5 !important;
}

.leaflet-popup-tip {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1) !important;
}

/* Contenu des popups */
.popup-alea {
    min-width: 250px;
    text-align: center;
}

.popup-alea h6 {
    margin-bottom: 0.75rem;
    color: #0d6efd;
    font-weight: 600;
}

.popup-alea .alea-niveau {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.popup-alea .description {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}

.popup-alea .btn-demande {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* ===========================================
   CONTRÔLES DE CARTE
   =========================================== */

.carte-controles {
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.carte-controles .input-group {
    border-radius: 8px;
    overflow: hidden;
}

.carte-controles .form-control {
    border: none;
    background: #f8f9fa;
}

.carte-controles .form-control:focus {
    background: white;
    box-shadow: none;
}

.carte-controles .btn {
    border: none;
    font-weight: 600;
}

/* Switch météo */
.form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* ===========================================
   COUCHES ET OVERLAYS
   =========================================== */

/* Contrôle des couches personnalisé */
.leaflet-control-layers {
    border-radius: 10px !important;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1) !important;
    border: none !important;
    background: white !important;
}

.leaflet-control-layers-toggle {
    background-image: none !important;
    background-color: #0d6efd !important;
    border-radius: 8px !important;
    color: white !important;
    font-family: 'Font Awesome 6 Free' !important;
    font-weight: 900 !important;
}

.leaflet-control-layers-toggle::before {
    content: '\f5fd'; /* Icône layers Font Awesome */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* ===========================================
   HEATMAP ET VISUALISATIONS
   =========================================== */

/* Heatmap des demandes */
.heatmap-point {
    border-radius: 50%;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.heatmap-point:hover {
    opacity: 1;
}

/* Clusters de marqueurs */
.marker-cluster {
    background: rgba(13, 110, 253, 0.8);
    border-radius: 50%;
    color: white;
    font-weight: bold;
    text-align: center;
    border: 2px solid white;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
}

.marker-cluster-small {
    width: 30px;
    height: 30px;
    line-height: 26px;
    font-size: 0.75rem;
}

.marker-cluster-medium {
    width: 40px;
    height: 40px;
    line-height: 36px;
    font-size: 0.875rem;
}

.marker-cluster-large {
    width: 50px;
    height: 50px;
    line-height: 46px;
    font-size: 1rem;
}

/* ===========================================
   ÉTATS DE LA CARTE
   =========================================== */

/* Carte en cours de chargement */
.carte-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #6c757d;
    background: #f8f9fa;
}

.carte-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
}

/* Carte en erreur */
.carte-erreur {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #dc3545;
    background: #f8f9fa;
    text-align: center;
    padding: 2rem;
}

.carte-erreur .fas {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Carte hors ligne */
.carte-hors-ligne {
    position: relative;
}

.carte-hors-ligne::after {
    content: 'Mode hors ligne';
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 1000;
}

/* ===========================================
   INFORMATIONS GÉOLOGIQUES
   =========================================== */

.infos-geologiques {
    background: white;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    margin-top: 1rem;
}

.infos-geologiques h5 {
    color: #0d6efd;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.infos-geologiques .coordonnees {
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 5px;
    font-size: 0.875rem;
}

.infos-geologiques .recommandations {
    background: #e3f2fd;
    border-left: 4px solid #0d6efd;
    padding: 0.75rem;
    margin-top: 0.75rem;
    border-radius: 0 5px 5px 0;
}

/* ===========================================
   ANIMATIONS SPÉCIFIQUES CARTE
   =========================================== */

/* Animation d'apparition des marqueurs */
.marqueur-apparition {
    animation: markerAppear 0.5s ease-out;
}

@keyframes markerAppear {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(90deg);
        opacity: 0.7;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Animation de sélection */
.marqueur-selectionne {
    animation: markerSelected 1s ease-in-out infinite alternate;
}

@keyframes markerSelected {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

/* ===========================================
   CONTRÔLES PERSONNALISÉS LEAFLET
   =========================================== */

/* Bouton de géolocalisation */
.leaflet-control-geolocation {
    background: white;
    border-radius: 8px;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    border: none;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.leaflet-control-geolocation:hover {
    background: #0d6efd;
    color: white;
    transform: scale(1.05);
}

.leaflet-control-geolocation.active {
    background: #198754;
    color: white;
}

/* Contrôle de recherche d'adresse */
.leaflet-control-search {
    background: white;
    border-radius: 8px;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    border: none;
    padding: 0.5rem;
    min-width: 200px;
}

.leaflet-control-search input {
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 0.5rem;
    width: 100%;
    font-size: 0.875rem;
}

.leaflet-control-search input:focus {
    border-color: #0d6efd;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* ===========================================
   LÉGENDE INTÉGRÉE À LA CARTE
   =========================================== */

.leaflet-control-legend {
    background: white;
    border-radius: 10px;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    border: none;
    padding: 1rem;
    max-width: 200px;
}

.leaflet-control-legend h6 {
    margin-bottom: 0.75rem;
    color: #0d6efd;
    font-weight: 600;
    font-size: 0.875rem;
}

.leaflet-control-legend .legende-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}

.leaflet-control-legend .legende-couleur {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ===========================================
   TOOLTIPS ET INFOBULLES
   =========================================== */

/* Tooltip personnalisé pour les marqueurs */
.leaflet-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    border: none !important;
    border-radius: 5px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    padding: 0.5rem 0.75rem !important;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2) !important;
}

.leaflet-tooltip-top:before {
    border-top-color: rgba(0, 0, 0, 0.8) !important;
}

.leaflet-tooltip-bottom:before {
    border-bottom-color: rgba(0, 0, 0, 0.8) !important;
}

.leaflet-tooltip-left:before {
    border-left-color: rgba(0, 0, 0, 0.8) !important;
}

.leaflet-tooltip-right:before {
    border-right-color: rgba(0, 0, 0, 0.8) !important;
}

/* ===========================================
   INDICATEURS DE CHARGEMENT CARTE
   =========================================== */

/* Overlay de chargement */
.carte-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 15px;
}

.carte-loading-content {
    text-align: center;
    color: #0d6efd;
}

.carte-loading-content .spinner-border {
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.5rem;
}

/* Barre de progression pour chargement des tuiles */
.carte-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #e9ecef;
    z-index: 1001;
    border-radius: 15px 15px 0 0;
    overflow: hidden;
}

.carte-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0d6efd, #198754);
    width: 0%;
    transition: width 0.3s ease;
}

/* ===========================================
   MODES D'AFFICHAGE CARTE
   =========================================== */

/* Mode plein écran */
.carte-plein-ecran {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9999 !important;
    border-radius: 0 !important;
    height: 100vh !important;
}

.carte-plein-ecran .leaflet-control-fullscreen {
    background: #dc3545 !important;
    color: white !important;
}

/* Bouton plein écran */
.leaflet-control-fullscreen {
    background: white;
    border-radius: 8px;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    border: none;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.leaflet-control-fullscreen:hover {
    background: #0d6efd;
    color: white;
    transform: scale(1.05);
}

/* ===========================================
   RESPONSIVE CARTE
   =========================================== */

/* Ajustements mobile */
@media (max-width: 767.98px) {
    .leaflet-control-legend {
        max-width: 150px;
        padding: 0.75rem;
    }
    
    .leaflet-control-search {
        min-width: 150px;
    }
    
    .popup-alea {
        min-width: 200px;
    }
    
    .marqueur-alea {
        width: 25px;
        height: 25px;
        font-size: 0.7rem;
    }
}

/* Ajustements tablette */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .carte-container {
        height: 450px;
    }
    
    .leaflet-control-legend {
        max-width: 180px;
    }
}

/* ===========================================
   ACCESSIBILITÉ CARTE
   =========================================== */

/* Focus visible pour les contrôles */
.leaflet-control-zoom a:focus,
.leaflet-control-geolocation:focus,
.leaflet-control-fullscreen:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Texte alternatif pour les marqueurs */
.marqueur-alea[aria-label] {
    position: relative;
}

/* Mode contraste élevé */
@media (prefers-contrast: high) {
    .marqueur-alea {
        border-width: 4px;
        border-color: #000;
    }
    
    .leaflet-popup-content-wrapper {
        border: 2px solid #000 !important;
    }
}

/* ===========================================
   OPTIMISATIONS PERFORMANCE
   =========================================== */

/* GPU acceleration pour les animations */
.marqueur-alea,
.leaflet-control-zoom a,
.leaflet-control-geolocation {
    will-change: transform;
    transform: translateZ(0);
}

/* Optimisation du rendu des tuiles */
.leaflet-tile {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ===========================================
   THÈME SOMBRE (OPTIONNEL)
   =========================================== */

@media (prefers-color-scheme: dark) {
    .carte-controles {
        background: #2d2d2d !important;
        border-color: #404040 !important;
    }
    
    .carte-controles .form-control {
        background: #1a1a1a !important;
        border-color: #404040 !important;
        color: white !important;
    }
    
    .leaflet-control-legend {
        background: #2d2d2d !important;
        color: white !important;
    }
    
    .infos-geologiques {
        background: #2d2d2d !important;
        color: white !important;
    }
}