/* =====================================================
   RESET ET BASE
===================================================== */

html, body {
  margin: 0;
  height: 100%;
  font-family: Arial, Helvetica, sans-serif;
}  

/* Conteneur principal */
#content {
  display: flex;
  height: 99%;
  background: linear-gradient(to right, rgba(230,250,250,1), white);
  align-items: center;
}

/* =====================================================
   CARTE
===================================================== */
#divcarte {
    flex: 2;
    min-height: 350px;
    height: 90vh;
}

#divcarte {
    position: relative; /* ajouté */
}


@media (max-width: 768px) {
    #divcarte {
        height: 55vh;
    }
}

/* =====================================================
   CONTRÔLES
===================================================== */
#control {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px;
  height: 100%;
  text-align: center;
}

/* Sections intro et note */
#intro, #note {
  flex: 1;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#note {
  min-height: 300px;
}

#commentaires {
  max-height: 200px;       /* Hauteur max du conteneur */
  overflow-y: auto;
  overflow-x: hidden;
  text-align: justify;
  padding: 5px;
  border: 2px solid black;
  display: flex;
  flex-direction: column;
  gap: 5px;                /* espace entre commentaires et textarea */
}

/* Cacher éléments */
.hidden, .hidden1, .hidden2 {
  display: none;
}

/* Texte et mots 
#communes {
  overflow-wrap: break-word;
  font-size: 14px;
  text-align: left;
} */
#communes label {
    overflow-wrap: break-word;
	text-align: left;        /* supprime le justifié */
    white-space: nowrap;     /* empêche l’étirement */
    display: inline-block;   /* largeur = texte */
}

.cfdf-tooltip {
    white-space: normal;
    min-width: 300px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
    display: flex;          /* important */
    flex-direction: column; /* empile le texte de haut en bas */
    justify-content: flex-start; /* aligne le texte en haut */
}

/* Enlève la bordure de focus sur les éléments interactifs comme path, polygon, polyline */
path:focus,
polygon:focus,
polyline:focus {
    outline: none;  /* Désactive la bordure de focus */
}




/* =====================================================
   LEAFLET POPUPS
===================================================== */
/* =====================================================
   VARIABLES GLOBALES
===================================================== */
/* Reset et base */
:root {
  --popup-img-max-height: 350px;
}

/* =====================================================
   POPUP LEAFLET - CONTENEUR
===================================================== */
.leaflet-popup-content,
.leaflet-popup-content-wrapper.custom-popup {
    width: auto !important;
    max-width: var(--popup-img-max-size) !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    box-sizing: border-box;
}

/* Style popup custom */
.leaflet-popup-content.custom-popup {
    white-space: normal !important;
    background: #e93434;
    color: white;
    text-align: center;
    padding: 10px;
}

.leaflet-popup-content-wrapper.custom-popup {
    background-color: #e93434;
    border: 2px solid #c82121;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    display: inline-block;
}

.leaflet-popup-tip.custom-popup {
    background-color: #e93434;
}

/* =====================================================
   IMAGE DANS LE POPUP
===================================================== */

/* Images dans popup */
.popup-img {
  max-height: var(--popup-img-max-height); /* permet de jouer sur la taille des popup*/
  height: auto;
  width: auto;
  display: block;
  margin: 0 auto;
}

/* Override potentiel de Leaflet */
.leaflet-popup-content img {
    width: auto; /* ← important ! */
    max-width: var(--popup-img-max-size);
    height: auto;
    max-height: var(--popup-img-max-height);
    display: block;
    margin: 0 auto;
}

/* =====================================================
   FORMULAIRE DE COMMENTAIRE
===================================================== */
.leaflet-popup-content form {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center; 
    gap: 8px;
    margin: 0;
}

.leaflet-popup-content form textarea {
    width: 100% !important;           
    max-width: var(--popup-img-max-size) !important;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #ccc;
    resize: vertical; /* autorise uniquement le redimensionnement vertical */
}

.leaflet-popup-content form button {
    width: 100% !important;           
    max-width: var(--popup-img-max-size) !important;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #ccc;
	background-color: #fff;
    color: #e93434;
    cursor: pointer;
}

.leaflet-popup-content form button:hover {
    background-color: #f2f2f2;
}

/* Popup interne */
.leaflet-popup-content .popup-inner {
    text-align: center;
    margin: 0 auto;
    display: inline-block;
}

/* Popups toujours au-dessus */
.leaflet-popup {
    z-index: 1000 !important;
}

/* =====================================================
   EXTRAS
===================================================== */
.popup-extra {
  margin-top: 10px;
}

/* Boutons */
.boutons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 6px;
}

.btn-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-img {
  cursor: pointer;
  width: 24px;
  height: 24px;
}

/* Messages like */
.like-msg {
  color: #27ae60;
  font-size: 0.9em;
}

.like-msg.error {
  color: #e74c3c;
}

/* Icônes */
.icon {
  position: relative;
}

/* Commandes */
.command {
  padding: 4px 6px;
  background: rgba(255,255,255,0.8);
  font: 14px/16px Arial, Helvetica, sans-serif;
  box-shadow: 0 0 15px rgba(0,0,0,0.2);
  border-radius: 5px;
  min-width: 200px;
}

/* Image */
#image.a { 
  position: relative;
  z-index: 1;
}

#image {
  overflow-x: auto;
  overflow-y: hidden;
  max-height: 300px;
}

/* =====================================================
   LISTE DES ÉDITEURS
===================================================== */
.editeurs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.editeurs-header label {
    font-weight: bold;
}

.editeurs-header #select-all-btn {
    margin: 0;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
}

#editeurs-container {
    margin-top: 10px;
    text-align: left;
    display: none; /* caché par défaut */
}

#editeurs-list {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 4px;
    background: #fff;
    -webkit-overflow-scrolling: touch; /* inertie iOS */
}

#editeurs-list div {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
}

#editeurs-list label {
    margin-left: 5px;
}

#editeurs-list input:not(:checked) + label {
    opacity: 0.5;
    text-decoration: line-through;
}

#select-all-btn {
    margin-top: 5px;
    margin-bottom: 5px;
}

.transparent-tooltip {
  background-color: transparent !important; /* fond transparent */
  border: none !important;                  /* supprime la bordure */
  box-shadow: none !important;              /* supprime l'ombre */
  padding: 0 !important;                    /* supprime l'espace interne */
  color: black !important;                  /* couleur du texte */
  font-weight: bold;
  font-size: 12px;
  text-shadow: 0 0 2px white;               /* optionnel pour lisibilité */
}



/* =====================================================
   CONTRÔLE SLIDERS LEAFLET (TRANSPARENT & REPLIABLE)
===================================================== */

.slider-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 500;
    pointer-events: auto;
    display: none; /* caché tant qu'aucune commune sélectionnée */
}

.settings-button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    border: none;
}

.settings-button img {
    width: 22px;
    height: 22px;
}

.control-sliders {
    position: absolute;
    top: 0;
    right: 45px;
    width: 200px;
    max-height: 0;
    overflow: hidden;
    padding: 0 10px;
    background: transparent;
    transition: max-height 0.35s ease-in-out, padding 0.3s;
}

.control-sliders.open {
    max-height: 400px;
    padding: 10px;
}

.control-sliders label {
    font-size: 13px;
    font-weight: bold;
}

.control-sliders input[type="range"] {
    width: 100%;
}


/* =====================================================
   ZONE RECHERCHE PAR MOTS CLÉS
===================================================== */
#search-container {
    margin-top: 10px;
    text-align: left;
}

#search-container label {
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
}

.search-wrapper {
    position: relative;
}

#searchCPA {
    width: 100%;
    padding: 6px 28px 6px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

#searchCPA:focus {
    outline: none;
    border-color: #4a90e2;
}

#searchCPA.active {
    border-color: #4a90e2;
    background: #f5faff;
}

#clearSearch {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    display: none;
}

#search-count {
    font-size: 12px;
    margin-top: 4px;
    color: #555;
}

/* =====================================================
   UTILITAIRES
===================================================== */
.leaflet-container:fullscreen {
    height: 100vh !important;
}

.leaflet-container:-webkit-full-screen {
    height: 100vh !important;
}

.highlight {
    background: #fff59d;
    padding: 0 2px;
    border-radius: 2px;
}


/* =====================================================
   MOBILE RESPONSIVE / IOS
===================================================== */
@media (max-width: 768px) {

    /* Popups Leaflet */
    .leaflet-popup-content,
    .leaflet-popup-content-wrapper.custom-popup {
        max-width: 90vw !important;
    }

    .popup-img,
    .leaflet-popup-content form input[type="text"],
    .leaflet-popup-content form button {
        max-width: 90vw !important;
    }

    /* Éviter zoom automatique sur iOS */
    .commune-select,
    #searchCPA {
        font-size: 16px;
        padding: 10px;
    }

    button,
    input[type="checkbox"] {
        min-height: 44px;
    }

    #clearSearch {
        font-size: 18px;
    }

    #select-all-btn {
        padding: 8px 12px;
        font-size: 14px;
    }

    #editeurs-list {
        max-height: 180px;
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch; /* inertie iOS */
    }

    #editeurs-container {
        max-height: 200px;
        overflow-y: auto;
    }

    /* Toujours en haut à droite, mais flottant sur mobile */
    #divcarte .slider-wrapper {
        top: 50% !important;      /* milieu vertical */
        right: 10px !important;    /* à droite */
        transform: translateY(-50%) !important; /* recentre verticalement */
    }

    .control-sliders {
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .control-sliders.open {
        max-height: 50vh !important;
        padding: 10px;
    }

    .settings-button img {
        width: 25px;
        height: 25px;
    }
}


/* =====================================================
   LISTE DES COMMUNES
===================================================== */
.commune-select {
    width: 280px;
    max-width: 100%;
    padding: 6px 10px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
}
