/* ============================================================================
   STYLES DE BASE
   ============================================================================ */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: 'Open Sans Regular', sans-serif;
    font-size: 13px;
    font-weight: 400;
}

.container-fluid {
    height: 100%;
    display: flex;
    flex-direction: column;
    font-family: 'Open Sans Regular', sans-serif;
    font-size: 13px;
    font-weight: 400;
}

#row_map {
    background-color: white;
    height: 100%;
    width: 100%;
    font-family: 'Open Sans Regular', sans-serif;
    font-size: 14px;
    font-weight: 400;
}

#map {
    width: 100%;
    height: 100%;
    font-family: 'Marble-Bold', sans-serif;
    font-size: 13px;
    font-weight: 400;
}

/* ============================================================================
   SCROLLBARS
   ============================================================================ */

.scrollcorps {
    overflow-y: auto;
    max-height: calc(100dvh - 150px);
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.3) #f8f9fa;
}

.scrollcorps::-webkit-scrollbar {
    width: 6px;
}

.scrollcorps::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 0px;
}

.scrollcorps::-webkit-scrollbar-thumb {
    background-color: #f8f9fa;
    border-radius: 0px;
    border-left: 1px solid rgba(0,0,0,0.3);
}

.scrollcorps::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.5); 
}

/* ============================================================================
   FOCUS ET INPUTS
   ============================================================================ */

textarea:focus,
input:focus,
input[type="button"]:focus {
    outline: none;
}

/* ============================================================================
   FONT AWESOME ICONS
   ============================================================================ */
.fa-refresh {
    color: #f8f9fa;
}
.fa-arrows-rotate {
    color: #9370DB;
}
.progbar .fa-arrows-rotate {
    color: #f8f9fa;
}
.fa-external-link {
    color: #0278be;
    font-weight: 600;
}
.fa-external-link:hover {
    cursor: pointer;
    color: red;
}

/* ============================================================================
   CHECKBOXES - FILTRES
   ============================================================================ */

#fen_service {
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #4fcd62;
}
#fen_service:hover {
    cursor: pointer;
}
#fen_travaux {
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #ffa500;
}
#fen_travaux:hover {
    cursor: pointer;
}
#fprojet {
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #4fa1cd;
}
#fprojet:hover {
    cursor: pointer;
}

/* ============================================================================
   POPUPS
   ============================================================================ */

.maplibregl-popup {
   max-width: 600px !important;
}

.popupcc_en_service .maplibregl-popup-content {
    background-color: #4fcd62;
    color: white;
    padding: 5px;
    font-weight: 500;
}
.popupcc_en_service .maplibregl-popup-tip {
    border-right-color: #4fcd62;
    border-width: 5px;
}
.popupdet_en_service .maplibregl-popup-content {
    padding: 0px;
    font-weight: 600;
    border: 2px solid #4fcd62;
    border-radius: 10px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.7);
    box-shadow: none;
    background: #f8f9fa;
    /* Largeur adaptative */
    max-width: 90vw;
    min-width: 250px;
    width: max-content;
}
.popupdet_en_service .maplibregl-popup-tip {
    border-top-color: #4fcd62;
    border-width: 10px;
}
.adherent_en_service {
    background: linear-gradient(135deg, rgba(79, 205, 98, 0.1), rgba(79, 205, 98, 0.05));
    padding: 1rem;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color:white;
}

.popupcc_en_travaux .maplibregl-popup-content {
    background-color: #ffa500;
    color: white;
    padding: 5px;
    font-weight: 500;
}
.popupcc_en_travaux .maplibregl-popup-tip {
    border-right-color: #ffa500;
    border-width: 5px;
}
.popupdet_en_travaux .maplibregl-popup-content {
    padding: 0px;
    font-weight: 600;
    border: 2px solid #ffa500;
    border-radius: 10px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.7);
    box-shadow: none;
    background: #f8f9fa;
    /* Largeur adaptative */
    max-width: 90vw;
    min-width: 250px;
    width: max-content;
}
.popupdet_en_travaux .maplibregl-popup-tip {
    border-top-color: #ffa500;
    border-width: 10px;
}
.adherent_en_travaux {
    background: linear-gradient(135deg, rgba(255, 165, 0, 0.1), rgba(255, 165, 0, 0.05));
    padding: 1rem;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color:white;
}

.popupcc_projet .maplibregl-popup-content {
    background-color: #4fa1cd;
    color: white;
    padding: 5px;
    font-weight: 500;
}
.popupcc_projet .maplibregl-popup-tip {
    border-right-color: #4fa1cd;
    border-width: 5px;
}
.popupdet_projet .maplibregl-popup-content {
    padding: 0px;
    font-weight: 600;
    border: 2px solid #4fa1cd;
    border-radius: 10px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.7);
    box-shadow: none;
    background: #f8f9fa;
    /* Largeur adaptative */
    max-width: 90vw;
    min-width: 250px;
    width: max-content;
}
.popupdet_projet .maplibregl-popup-tip {
    border-top-color: #4fa1cd;
    border-width: 10px;
}
.adherent_projet {
    background: linear-gradient(135deg, rgba(79, 161, 205, 0.1), rgba(79, 161, 205, 0.05));
    padding: 1rem;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color:white;
}

.maplibregl-popup-close-button {
    color: #ffffff;
    top: 5px;
    right: 5px;
    font-size: 14px;
    font-weight: 400;
    width: 20px;
    height: 20px;
    text-align: center;
    border: 1px solid #ffffff;
    border-radius: 4px;
    z-index: 10001;
    padding: 0;
}
.maplibregl-popup-close-button:hover {
    cursor: pointer;
    background-color: #ffffff;
    border-color: #ffffff;
    color: rgba(0, 0, 0, 0.7);
}
.cadre {
    margin: 0 8px 1rem 8px;
    padding: 6px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}


/* ============================================================================
   MAPLIBRE CONTRÔLES
   ============================================================================ */

.maplibregl-ctrl-group {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 0 0 2px rgba(0,0,0,.1);
}

.maplibregl-ctrl-group button {
    width: 30px;
    height: 30px;
    display: block;
    padding: 0;
    outline: none;
    border: 0;
    background-color: transparent;
    cursor: pointer;
}

.maplibregl-ctrl-group button:hover {
    background-color: rgba(0,0,0,.05);
}


/* ============================================================================
   BANDEAU PRINCIPAL - PLEINE LARGEUR PC + DÉPLOYABLE MOBILE
   ============================================================================ */

.bandeau-container {
    max-width: none !important;
    width: calc(100vw - 20px) !important;
}

#row_bandeau {
    background: linear-gradient(to top, #ecedee, #ffffff);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: calc(100vw - 20px) !important;
    padding: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    position: relative;
}

.bandeau-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 0 0.75rem 1rem;
    gap: 1rem;
    flex-shrink: 0;
}

.bandeau-logo img {
    height: 50px;
    width: auto;
}

.bandeau-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: #363b40;
    cursor: pointer;
    padding: 0.5rem;
}

.bandeau-toggle:hover {
    color: #4fa1cd;
}

.bandeau-refresh {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.bandeau-content {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2rem;
    padding: 0.75rem 1rem;
    padding-right: 5rem;
    flex-wrap: nowrap;
    flex: 1;
}

.btn-refresh {
    background: linear-gradient(135deg, #9370DB, #7a5bc4);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(147, 112, 219, 0.3);
}

.btn-refresh:hover {
    background: linear-gradient(135deg, #7a5bc4, #6a4bb4);
    transform: rotate(180deg) scale(1.05);
    box-shadow: 0 4px 8px rgba(147, 112, 219, 0.4);
}

.btn-refresh i {
    font-size: 20px;
}

/* Groupes de filtres */
.filter-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 30px;
    border: 1px solid rgba(72, 72, 72, 0.2);
    border-radius: 6px;
    padding:0;
}

.slider-group {
    flex: 1;
    min-width: 250px;
    max-width: 300px;
}

.filter-title {
    font-weight: 600;
    font-size: 15px;
    color: rgba(72, 72, 72, 0.8);
    text-align: center;
    white-space: nowrap;
    border-bottom: 1px solid rgba(72, 72, 72, 0.1);
    width:100%;
    padding: 8px 0 8px 0;
}

.filter-checkboxes {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: center;
    padding: 8px;
}


.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    padding: 7px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    justify-content: flex-start;
}

.checkbox-label:hover {
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: "✓";
    color: #fff;
    font-weight: bold;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"]:not(:checked) + .checkbox-custom {
    background: #fff !important;
    border: 2px solid #ddd;
}

.checkbox-text {
    font-size: 14px;
    font-weight: 500;
    color: #363b40;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-left: 4px;
    padding-right: 4px;
}

.checkbox-text i {
    font-size: 18px;
    margin-right:4px;
}

.slider-wrapper {
    width: 90%;
    height:36px;
    margin: 8px 0 8px 0;
}

/* ============================================================================
   RESPONSIVE - MOBILE
   ============================================================================ */

@media screen and (max-width: 768px) {
    .bandeau-container {
        width: calc(100vw - 10px) !important;
    }

    /* En mobile : remettre en mode colonne */
    #row_bandeau {
        border-radius: 8px;
        flex-direction: column;
        gap: 0;
        position: static;
    }

    .bandeau-header {
        padding: 0.5rem 0.75rem;
        width: 100%;
        justify-content: flex-start;
        gap: 0.5rem;
    }

    .bandeau-logo {
        flex-shrink: 0;
    }

    .bandeau-logo img {
        height: 40px;
    }

    /* Afficher le bouton toggle sur mobile */
    .bandeau-toggle {
        display: block;
        margin: auto;
    }

    /* Refresh reste dans le flux normal en mobile */
    .bandeau-refresh {
        position: static;
        transform: none;
        margin-left: 0;
    }

    .btn-refresh {
        width: 40px;
        height: 40px;
    }

    .btn-refresh i {
        font-size: 18px;
    }

    /* Contenu déployable */
    .bandeau-content {
        order: 2;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
        padding: 0 1rem;
        flex-direction: column;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .bandeau-content.show {
        max-height: 500px;
        opacity: 1;
        padding: 1rem;
    }

    .filter-group {
        width: 100%;
        margin-left: 0;
    }

    .filter-checkboxes {
        flex-direction: column;
        flex-wrap: wrap;
        gap: 0.75rem;
        width: 100%;
    }

    .checkbox-label {
        width: 100%;
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.5);
        border-radius: 6px;
        justify-content: flex-start;
    }

    .slider-group {
        width: 100%;
        max-width: none;
    }
    
    /* Popups responsives en mobile */
    .popupdet_en_service .maplibregl-popup-content,
    .popupdet_en_travaux .maplibregl-popup-content,
    .popupdet_projet .maplibregl-popup-content {
        max-width: 85vw;
        min-width: 200px;
    }
}

/* Très petit mobile */
@media screen and (max-width: 375px) {
    .bandeau-logo img {
        height: 35px;
    }

    .btn-refresh {
        width: 36px;
        height: 36px;
    }

    .btn-refresh i {
        font-size: 16px;
    }

    .filter-title {
        font-size: 12px;
    }

    .checkbox-text {
        font-size: 13px;
    }
    
    /* Popups très petits écrans */
    .popupdet_en_service .maplibregl-popup-content,
    .popupdet_en_travaux .maplibregl-popup-content,
    .popupdet_projet .maplibregl-popup-content {
        max-width: 90vw;
        min-width: 180px;
        font-size: 12px;
    }
}

/* Desktop (min 769px) - S'assurer que le bandeau reste sur 1 ligne */
@media screen and (min-width: 769px) {
    .bandeau-content {
        flex-wrap: nowrap !important;
    }
    
    .filter-checkboxes {
        flex-wrap: nowrap !important;
    }
    
    /* Popups largeur optimale en desktop */
    .popupdet_en_service .maplibregl-popup-content,
    .popupdet_en_travaux .maplibregl-popup-content,
    .popupdet_projet .maplibregl-popup-content {
        max-width: 600px !important;
    }
}

/* Tablets (769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .bandeau-content {
        gap: 1.5rem;
        padding: 0 0.75rem 0.75rem 0.75rem;
    }
    
    .filter-checkboxes {
        gap: 1rem;
    }
    
    .checkbox-text {
        font-size: 13px;
    }
    
    .slider-group {
        min-width: 200px;
        max-width: 300px;
    }
    
    .maplibregl-popup-content {
        font-size: 13px;
    }
}

/* Desktop (défaut - déjà dans app.css) */
@media screen and (min-width: 1025px) {
    /* Les styles desktop sont déjà dans app.css */
}

/* ============================================================================
   RESPONSIVE - LANDSCAPE MOBILE
   ============================================================================ */

@media screen and (max-width: 768px) and (orientation: landscape) {
    
    #row_bandeau {
        max-height: 120px;
        overflow-y: auto;
    }
    
    #collapsefiltres {
        max-height: 100px;
        overflow-y: auto;
    }
    
    .deprep {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    #qte_select {
        flex-direction: row !important;
        margin-left: 10px !important;
    }
}

/* ============================================================================
   ANIMATIONS ET TRANSITIONS
   ============================================================================ */


@keyframes fadeInPopup {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


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

/* Accélération matérielle pour les popups */
.maplibregl-popup-content {
    /* will-change: transform; */
    backface-visibility: hidden;
}

/* Smooth scrolling pour le bandeau si nécessaire */
#row_bandeau {
    scroll-behavior: smooth;
}

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

/* Focus visible pour les contrôles */
input[type="checkbox"]:focus,
button:focus,
a:focus {
    outline: 2px solid #4fa1cd;
    outline-offset: 2px;
}

/* Taille minimum des zones tactiles (44x44px recommandé) */
@media (hover: none) and (pointer: coarse) {
    button,
    a,
    input[type="checkbox"] {
        min-width: 44px;
        min-height: 44px;
    }
    
    .deprep label {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ============================================================================
   DARK MODE (si besoin futur)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    /* Optionnel : ajouter des styles pour le mode sombre */
}

/* ============================================================================
   PRINT STYLES (impression de la carte)
   ============================================================================ */

@media print {
    #row_bandeau {
        display: none;
    }
    
    .maplibregl-ctrl {
        display: none;
    }
    
    #map {
        width: 100%;
        height: 100vh;
    }
}

/* ============================================================================
   UTILITAIRES RESPONSIVE
   ============================================================================ */

/* Masquer sur mobile */
.hide-mobile {
    display: block;
}

@media screen and (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Afficher uniquement sur mobile */
.show-mobile {
    display: none;
}

@media screen and (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* ============================================================================
   LOADER / SPINNER (pour le chargement des données)
   ============================================================================ */

.map-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

.map-loader-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #4fa1cd;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================================================
   AMÉLIORATIONS DES POPUPS
   ============================================================================ */

/* Meilleure lisibilité des popups */
.popupdet_en_service .adherent_en_service,
.popupdet_projet .adherent_projet,
.popupdet_en_travaux .adherent_en_travaux{
    padding: 1rem 30px 1rem 30px;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    line-height: 1.4;
}
.popupdet_en_service .adherent_en_service{
    background: rgba(79, 205, 98, 1);
}
.popupdet_en_travaux .adherent_en_travaux {
    background: rgba(255,165,0,1);
}
.popupdet_projet .adherent_projet {
    background: rgba(79, 161, 205, 1);
}


/* ============================================================================
   OPTIMISATIONS DU SLIDER
   ============================================================================ */

.irs {
    font-family: 'Open Sans Regular', sans-serif;
}

.irs--flat .irs-grid-text {
    font-size: 10px;
}

.irs--flat {
    height:20px;
}

@media screen and (max-width: 768px) {
    .irs {
        font-size: 10px;
    }
    
    .irs--flat .irs-handle {
        width: 18px;
        height: 18px;
    }

    .irs--flat .irs-line {
        height: 6px;
    }

    .irs--flat .irs-bar {
        height: 6px;
    }

    .irs--flat .irs-from,
    .irs--flat .irs-to,
    .irs--flat .irs-single {
        font-size: 10px;
        padding: 1px 3px;
    }

    .irs--flat .irs-grid-text {
        font-size: 8px;
    }

    .irs--flat .irs-grid-pol {
        height: 4px;
    }
}

/* ============================================================================
   CORRECTION DES PROBLÈMES COURANTS
   ============================================================================ */

@media screen and (max-width: 768px) {
    .maplibregl-popup-anchor-top .maplibregl-popup-content {
        margin-top: 10px;
    }
    
    .maplibregl-popup-anchor-bottom .maplibregl-popup-content {
        margin-bottom: 10px;
    }
}

/* Fix pour le zoom sur double-tap iOS */
.maplibregl-canvas-container {
    touch-action: pan-x pan-y;
}

/* Empêcher la sélection de texte lors du drag de la carte */
.maplibregl-canvas-container * {
    user-select: none;
    -webkit-user-select: none;
}

/* ============================================================================
   PERSONNALISATION DES CLUSTERS
   ============================================================================ */

/* Amélioration visuelle des clusters */
.maplibregl-canvas:hover {
    cursor: grab;
}

.maplibregl-canvas:active {
    cursor: grabbing;
}

/* Style pour les clusters qui apparaissent/disparaissent */
[class*="cluster"] {
    transition: opacity 0.3s ease;
}

/* ============================================================================
   RESPONSIVE POUR TRÈS PETITS ÉCRANS
   ============================================================================ */

@media screen and (max-width: 375px) {
    
    #row_bandeau {
        font-size: 10px;
    }
    
    #row_bandeau img {
        height: 30px !important;
    }
    
    .deprep label {
        font-size: 11px;
        padding: 0.25rem;
    }
    
    .maplibregl-popup-content {
        font-size: 11px;
        padding: 6px;
    }
    
    .cadre {
        font-size: 10px;
        padding: 0.4rem;
    }
}

/* ============================================================================
   PERFORMANCE - RÉDUCTION DE LA COMPLEXITÉ VISUELLE
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
