/**
 * map.css
 * Styles pour la carte interactive et ses composants
 * Dépend de variables.css pour les couleurs et les valeurs communes
 */

/* ========================================================================== */
/* MISE EN PAGE GÉNÉRALE DE LA CARTE
/* ========================================================================== */

/* Styles pour la page de carte */
.page-map {
    overflow: hidden;
}

/* Conteneur de carte en pleine largeur */
.map-fullwidth {
    position: relative;
    width: 100vw;
    height: calc(100vh - 56px - 30px); /* Hauteur de l'écran moins la hauteur du header et du footer */
    margin: 0;
    padding: 0;
}

#map-container {
    width: 100%;
    height: 100%;
    z-index: 1;
}

#map {
    width: 100%;
    height: calc(100vh - 6rem);
}

/* ========================================================================== */
/* CONTRÔLES LEAFLET ET AJUSTEMENTS
/* ========================================================================== */

/* Masquer les contrôles de dessin natifs de Leaflet */
.leaflet-draw.leaflet-control {
    display: none;
}

/* Masquer le popup de mesure dans le coin inférieur droit */
.leaflet-control-measure,
.leaflet-measure-resultpopup,
.leaflet-popup.leaflet-measure-popup {
    display: none !important;
}

/* S'assurer que les contrôles de zoom sont bien en haut à gauche */
.leaflet-top.leaflet-left {
    top: 10px;
    left: 10px;
}

/* Masquer le popup de mesure par son ID */
#measurement-result,
.measurement-result {
    display: none !important;
}

/* Masquer tout popup non-spécifique dans le coin inférieur droit */
.leaflet-bottom.leaflet-right .leaflet-popup,
.leaflet-bottom.leaflet-right .leaflet-popup-content-wrapper {
    display: none !important;
}

/* Ajuster la position des autres contrôles pour éviter les chevauchements */
.leaflet-top.leaflet-right {
    top: 10px !important; /* Déplacé plus bas pour laisser de la place au sélecteur */
    right: 10px !important;
}

html body .leaflet-container {
    font-family: 'Poppins', sans-serif !important;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}


/* ========================================================================== */
/* BARRE D'OUTILS DE LA CARTE
/* ========================================================================== */

/* Barre d'outils en bas de la carte */
.map-toolbar-bottom {
    position: absolute;
    bottom: 60px; /* Augmenter davantage la distance par rapport au bas pour être bien au-dessus du footer */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001; /* Valeur supérieure au z-index du footer (900) */
    background-color: transparent !important; /* Forcer la transparence */
    box-shadow: none !important; /* Supprimer toute ombre */
    padding: 0; /* Supprimer le padding */
    display: flex;
    justify-content: center;
}

.toolbar-buttons {
    display: flex;
    gap: 10px;
}

/* Boutons d'outils ronds */
.btn-tool {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: var(--secondary-color);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--box-shadow); /* Ajouter une ombre à chaque bouton */
    margin: 0 5px; /* Espacement entre les boutons */
    position: relative; /* Pour le positionnement de l'infobulle */
}

.btn-tool:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.btn-tool.active {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.btn-tool-danger {
    background-color: var(--delete-color);
    color: white;
}

.btn-tool-danger:hover {
    background-color: var(--red-color-hover);
}

/* Infobulle pour les boutons */
.btn-tool::after {
    content: attr(title);
    position: absolute;
    top: -30px; /* Positionner l'infobulle au-dessus du bouton */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1002; /* S'assurer que l'infobulle est au-dessus de tout */
}

.btn-tool:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ========================================================================== */
/* SÉLECTEUR DE TERRITOIRE ET MESURES
/* ========================================================================== */

/* Sélecteur de territoire - Aligné à droite des contrôles de zoom */
.territory-selector {
    position: absolute;
    top: 20px;
    left: 80px; /* Positionné à droite des contrôles de zoom */
    z-index: 1010;
    width: 250px;
    max-width: 90%;
    display: block !important;
}

/* Style amélioré pour le select */
.territory-selector select {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--dark-color);
}

.territory-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(58, 138, 61, 0.25);
}

/* Résultat de mesure */
.measurement-result {
    position: absolute;
    bottom: 80px;
    right: 10px;
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: var(--box-shadow-lg);
    z-index: 1000;
    min-width: 200px;
    max-width: 300px;
    border-left: 4px solid var(--primary-color);
}

.measurement-result h4 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.measurement-result p {
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.measurement-value {
    font-weight: bold;
    color: var(--primary-color);
}

#clear-measurement {
    background-color: #f0f0f0;
    border: none;
    color: var(--dark-color);
    padding: 5px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    font-weight: bold;
}

#clear-measurement:hover {
    background-color: #e0e0e0;
}

/* ========================================================================== */
/* NOTIFICATIONS ET ALERTES
/* ========================================================================== */

/* Styles pour les notifications */
.notification {
    background-color: white;
    color: var(--dark-color);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    opacity: 0;
    transform: translateX(50px);
    transition: var(--transition);
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left: 4px solid var(--success-color);
}

.notification-danger {
    border-left: 4px solid var(--delete-color);
}

.notification-warning {
    border-left: 4px solid var(--warning-color);
}

.notification-info {
    border-left: 4px solid var(--info-color);
}

/* ========================================================================== */
/* MODALES ET FORMULAIRES
/* ========================================================================== */

/* Styles pour les modales */
.modal-content {
    border-radius: var(--border-radius);
    overflow: hidden;
}

/* Les styles des modaux ont été déplacés vers /assets/css/modals/login-modal.css */

/* Les styles des onglets ont été déplacés vers /assets/css/modals/login-modal.css */

#locationModalTabContent{
    padding: 0px 0px;
}

/* ========================================================================== */
/* POPUPS ET INFOBULLES
/* ========================================================================== */

/* Styles pour les popups des enceintes */
.enclosure-popup h4 {
    margin : 5px 0px;
    color: var(--dark-color);
    font-size: 1.2rem;
}

.enclosure-popup p {
    margin: 0px;
    padding: 0px;
    color: var(--dark-color);       
}

.surface-info {
    padding: 0px 0px;
    font-size: 0.9rem;
    margin: 10px 0px;
    display: inline-block;
    color: var(--dark-color);
}

/* Styles unifiés pour les boutons des popups */
.popup-buttons {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    justify-content: space-between;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-sm.btn-primary {
    background-color: var(--edit-color);
    color: white;
}

.btn-sm.btn-danger {
    background-color: var(--delete-color);
    color: white;
}

.btn-sm.btn-primary:hover {
    background-color: var(--edit-color-hover);
}

.btn-sm.btn-danger:hover {
    background-color: var(--red-color-hover);
}

#useLocationNo {
    background-color: var(--delete-color);
    color: white;
}

#useLocationYes {
    background-color: var(--primary-color);
    color: white;
}

#messagePosition {
    margin: 0px;
    padding: 0px;
}

#toggleEditPosition, #toggleEditCirclePosition {
    background-color: var(--edit-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toggleEditPosition i {
    margin-right: 8px;
}

#toggleEditCirclePosition i {
    margin-right: 8px;
}

#toggleEditPosition:hover {
    background-color: var(--edit-color-hover);
}

#useCurrentPosition{
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-right: auto;
    margin-left: auto;
    display: flex;
    justify-content: space-between;
    display: flex;
    align-items: center;
    justify-content: center;
    
}

#useCurrentPositionIcon{
    margin-right: 8px;
}

/* ========================================================================== */
/* DROPDOWN PERSONNALISÉ POUR LES TYPES DE POINTS
/* ========================================================================== */

.custom-dropdown {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}

.custom-dropdown-selected {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    background-color: #fff;
    border-radius: 0.25rem;
}

.custom-dropdown-selected i {
    margin-right: 10px;
    font-size: 1.1em;
}

.custom-dropdown-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0 0 0.25rem 0.25rem;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.custom-dropdown.open .custom-dropdown-options {
    display: block;
}

.custom-dropdown-option {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.custom-dropdown-option:hover {
    background-color: #f8f9fa;
}

.custom-dropdown-option i {
    margin-right: 10px;
    font-size: 1.1em;
}

/* ========================================================================== */
/* CONTRÔLES DE DESSIN
/* ========================================================================== */

/* Styles pour les contrôles de dessin */
.drawing-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drawing-control-btn {
    background-color: white;
    border: none;
    border-radius: 4px;
    padding: 10px;
    box-shadow: var(--box-shadow);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.drawing-control-btn:hover {
    background-color: var(--light-color);
}

.drawing-control-btn.active {
    background-color: var(--primary-color);
    color: white;
}

/* Styles pour les boutons d'édition des cercles et flèches */
.btn-edit-enclosure {
    background-color: var(--edit-color);
    color: white;
}

.btn-edit-circle {
    background-color: var(--edit-color);
}

.btn-edit-arrow {
    background-color: var(--edit-color);
}

.btn-delete-circle, .btn-delete-arrow {
    background-color: var(--delete-color);
    color: white;
}

/* Styles pour le contrôle des outils de dessin personnalisé */
.leaflet-control-drawing-toggle-custom {
    width: 36px;
    height: 36px;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.65);
    cursor: pointer;
    margin-top: 10px;
}

.leaflet-control-drawing-toggle-custom a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #333;
    text-decoration: none;
}

.leaflet-control-drawing-toggle-custom a i {
    font-size: 18px;
}

/* ========================================================================== */
/* FORMULAIRES SPÉCIFIQUES
/* ========================================================================== */

/* Styles pour le formulaire d'édition des enceintes */
#enclosureForm .form-group {
    margin-bottom: 15px;
}

#enclosureForm label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

#enclosureForm input[type="text"],
#enclosureForm select,
#enclosureForm textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

#enclosureForm input[type="text"]:focus,
#enclosureForm select:focus,
#enclosureForm textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(58, 138, 61, 0.25);
}

/* Styles pour les options de style */
.style-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.color-picker-container {
    grid-column: 1 / -1;
}

.color-picker-container label {
    display: block;
    margin-bottom: 5px;
}

.color-preview {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 10px;
    border: 1px solid var(--border-color);
}

/* Styles pour les sliders */
.slider-container {
    margin-bottom: 15px;
}

.slider-container label {
    display: block;
    margin-bottom: 5px;
}

.slider-value {
    display: inline-block;
    width: 40px;
    text-align: center;
    margin-left: 10px;
}

input[type="range"] {
    width: calc(100% - 50px);
    vertical-align: middle;
}

/* Styles pour la prévisualisation */
.preview-container {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--light-color);
    text-align: center;
}

.preview-title {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--dark-color);
}

.preview-box {
    width: 100px;
    height: 100px;
    margin: 0 auto;
    border: 3px solid var(--primary-color);
    border-radius: 10px;
    background-color: rgba(58, 138, 61, 0.2);
}

/* ========================================================================== */
/* BOUTONS D'ACTION
/* ========================================================================== */

/* Styles pour les boutons d'action */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.action-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.btn-save {
    background-color: var(--primary-color);
    color: white;
}

.btn-save:hover {
    background-color: var(--primary-hover);
}

.btn-cancel {
    background-color: var(--delete-color);
    color: white;
}

.btn-cancel:hover {
    background-color: var(--red-color-hover);
}

/* Styles pour les boutons d'édition et de suppression */
.btn-edit-location, .btn-edit-enclosure {
    background-color: var(--edit-color);
    color: white;
}

.btn-delete-location, .btn-delete-enclosure {
    background-color: var(--delete-color);
    color: white;
}

/* ========================================================================== */
/* STYLES DES POPUPS LEAFLET
/* ========================================================================== */

/* Style pour le conteneur des popups Leaflet */
.leaflet-popup-content-wrapper {
    border-radius: var(--border-radius) !important;
    box-shadow: none !important; /* Supprimer l'effet d'ombre */
    border: none !important; /* Supprimer la bordure */
}

/* Style pour les actions dans les popups */
.popup-actions {
    display: flex;
    justify-content: space-between; /* Espacer les boutons */
    margin-top: 10px;
    width: 100%;
}

/* Style pour le bouton d'édition (à gauche) */
.popup-actions button:first-child {
    margin-right: auto; /* Positionner à gauche */
    box-shadow: none !important; /* Supprimer l'effet d'ombre */
    border: none !important; /* Supprimer la bordure */
}

/* Style pour le bouton de suppression (à droite) */
.popup-actions button:last-child {
    margin-left: auto; /* Positionner à droite */
    box-shadow: none !important; /* Supprimer l'effet d'ombre */
    border: none !important; /* Supprimer la bordure */
}

/* Ajuster la largeur des boutons pour qu'ils ne soient pas trop larges */
.popup-actions button {
    min-width: 80px;
    padding: 5px 10px;
    border-radius: var(--border-radius-sm);
}

#toggleEditBoundaries{
    background-color: var(--edit-color);
    color: white;
}

#toggleEditBoundaries:hover{
    background-color: var(--edit-color-hover);
    color: white;
}


/* ========================================================================== */
/* AJUSTEMENTS POUR L'ÉCHELLE ET LE COPYRIGHT LEAFLET
/* ========================================================================== */

/* Relever l'échelle et le copyright Leaflet au-dessus du footer */
.leaflet-bottom {
    bottom: 50px !important;
    font-size: 10px; /* Hauteur du footer */
}

/* Style spécifique pour l'échelle */
.leaflet-control-scale {
    margin-bottom: 10px !important;
    line-height: 1;
}

.leaflet-control-scale-line {
    line-height: 1;
}


/* Style spécifique pour le copyright */
.leaflet-control-attribution {
    margin-bottom: 10px !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    padding: 0 5px !important;
    border-radius: var(--border-radius-sm) !important;
    font-size: 10px !important;
}

/* Styles pour le contrôle des couches personnalisé */
.leaflet-control-layers-toggle-custom {
    width: 36px;
    height: 36px;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.65);
    cursor: pointer;
}

.leaflet-control-layers-toggle-custom a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #333;
    text-decoration: none;
}

.leaflet-control-layers-toggle-custom a i {
    font-size: 18px;
}

/* Icône de couches personnalisée (fallback si Font Awesome n'est pas disponible) */
.leaflet-control-layers-toggle-custom a::before {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M12.41 148.02l232.94 105.67c6.8 3.09 14.49 3.09 21.29 0l232.94-105.67c16.55-7.51 16.55-32.52 0-40.03L266.65 2.31a25.607 25.607 0 0 0-21.29 0L12.41 107.98c-16.55 7.51-16.55 32.53 0 40.04zm487.18 88.28l-58.09-26.33-161.64 73.27c-7.56 3.43-15.59 5.17-23.86 5.17s-16.29-1.74-23.86-5.17L70.51 209.97l-58.1 26.33c-16.55 7.5-16.55 32.5 0 40l232.94 105.59c6.8 3.08 14.49 3.08 21.29 0L499.59 276.3c16.55-7.5 16.55-32.5 0-40zm0 127.8l-57.87-26.23-161.86 73.37c-7.56 3.43-15.59 5.17-23.86 5.17s-16.29-1.74-23.86-5.17L70.29 337.87 12.41 364.1c-16.55 7.5-16.55 32.5 0 40l232.94 105.59c6.8 3.08 14.49 3.08 21.29 0L499.59 404.1c16.55-7.5 16.55-32.5 0-40z"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
}

/* Style pour le contrôle des couches */
.leaflet-control-layers {
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.leaflet-control-layers-expanded {
    padding: 10px;
    background-color: #fff;
    max-height: 300px;
    overflow-y: auto;
}

.leaflet-control-layers-selector {
    margin-right: 5px;
}

.leaflet-control-layers-separator {
    height: 0;
    border-top: 1px solid #ddd;
    margin: 5px -10px;
}

/* Styles pour le panneau des enceintes et territoires */
.enclosures-panel {
    background-color: white;
    padding: 15px;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    max-height: 400px; /* Augmenter la hauteur pour accommoder les deux listes */
    overflow-y: auto;
    width: 300px;
    position: absolute;
    top: 100px;
    right: 10px;
    z-index: 1000;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.enclosures-panel h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    text-align: center;
    font-weight: 600;
    font-size: var(--font-size-lg); 
    text-transform: uppercase;
}

.enclosures-list, .territories-list {
    margin-bottom: 10px;
}

.enclosure-item, .territory-item {
    margin: 0px 0px;
    display: flex;
    align-items: center;
    padding: 3px 0;
}

.enclosure-item input[type="checkbox"], 
.territory-item input[type="checkbox"] {
    margin-right: 8px;
}

.enclosure-item label, 
.territory-item label {
    flex: 1;
    cursor: pointer;
    font-size: var(--font-size-sm);
}

/* Style différent pour les territoires pour les distinguer visuellement */
.territory-item {
    background-color: rgba(58, 138, 61, 0.05);
    border-radius: 3px;
    padding: 3px 5px;
}

/* Séparateur entre les listes */
.enclosures-panel hr {
    border: 0;
    height: 0px;
    background-color: #eee;
    margin: 0px 0;
}

/* Styles pour les popups et tooltips des territoires */
.territory-popup h4 {
    margin: 0 0 5px 0;
    color: var(--primary-color);
    font-weight: bold;
}

.territory-popup p {
    margin: 0;
    font-size: 14px;
}

.territory-tooltip {
    background-color: rgba(153, 0, 71, 0.8);
    border: none;
    color: white;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.territory-tooltip::before {
    border-top-color: rgba(153, 0, 71, 0.8);
}

@media (max-width: 576px) {
    .leaflet-bottom {
        bottom: 0px !important;
        font-size: 10px; /* Hauteur du footer */
    }
}