/* Styles pour la carte des Castors */
.has-carte-castors #main .inner-wrap {
    max-width: 1600px;
    padding: 0 20px;
}

.has-carte-castors #main #primary {
    width: 100%;
}

.carte-castors-container {
    position: relative;
    display: flex;
    gap: 20px;
    align-items: flex-start;
    width: 100%;
}

.carte-castors-map-wrapper {
    flex: 1;
    position: relative;
}

.carte-castors-map {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-height: 700px;
}

.carte-castors-map button {
    margin-bottom: 0;
}

/* Formulaire de recherche */
.carte-castors-search {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    padding: 0;
    max-width: 300px;
    min-width: 250px;
}

.carte-castors-search-form {
    display: flex;
    align-items: center;
}

.carte-castors-search-input {
    flex: 1;
    border: none;
    padding: 10px 16px !important;
    font-size: 14px;
    border-radius: 6px 0 0 6px;
    outline: none;
    background: transparent;
    margin: 0 !important;
    height: 44px;
    border: none;
}

.carte-castors-search-input::placeholder {
    color: #999;
}

.carte-castors-search-btn {
    background: #7eaa01;
    border: none;
    color: white;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 0 6px 6px 0;
    font-size: 14px;
    transition: background-color 0.2s;
    margin: 0;
    display: flex;
}

.carte-castors-search-btn:hover {
    background: #6b9301;
}

.carte-castors-search-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.carte-castors-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
}

.carte-castors-search-result {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    transition: background-color 0.2s;
}

.carte-castors-search-result:hover {
    background: #f5f5f5;
}

.carte-castors-search-result:last-child {
    border-bottom: none;
}

.carte-castors-search-result-name {
    font-weight: 500;
    color: #333;
}

.carte-castors-search-result-details {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.carte-castors-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 350px;
    flex-shrink: 0;
}

/* Filtres */
.carte-castors-filters {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
}

/* Liste dynamique */
.carte-castors-listing {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 700px;
    display: flex;
    flex-direction: column;
}

.carte-castors-listing h4 {
    margin: 0;
    padding: 15px;
    color: #333;
    font-size: 16px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.listing-stats {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    font-size: 13px;
    color: #666;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.listing-stats .total-count {
    font-weight: 600;
    color: #333;
}

.listing-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.listing-empty {
    padding: 30px 15px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.listing-section {
    border-bottom: 1px solid #f0f0f0;
}

.listing-section:last-child {
    border-bottom: none;
}

.listing-section-header {
    padding: 12px 15px;
    background: #f8f9fa;
    font-weight: 600;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #eee;
}

.listing-section-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.listing-section-marker.adherents {
    background-color: #2E7D32;
}

.listing-section-marker.chantiers {
    background-color: #D32F2F;
}

.listing-section-marker.events {
    background-color: #ffb100;
}

.listing-items {
    max-height: 200px;
    overflow-y: auto;
}

.listing-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.listing-item:hover {
    background: #f8f9fa;
}

.listing-item:last-child {
    border-bottom: none;
}

.listing-item-title {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 1.3;
}

.listing-item-meta {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.listing-item-meta .meta-row {
    margin-bottom: 2px;
}

.listing-item-meta .meta-row:last-child {
    margin-bottom: 0;
}

.listing-item-distance {
    font-size: 11px;
    color: #999;
    font-style: italic;
    margin-top: 4px;
}

.listing-item.type-adherents.highlighted {
    background: #eafde3;
    box-shadow: 4px 0 0 #2e7d32 inset;
}

.listing-item.type-chantiers.highlighted {
    background: #fde3e3;
    box-shadow: 4px 0 0 #d32f2f inset;
}

.listing-item.type-events.highlighted {
    background: #fdf9e3;
    box-shadow: 4px 0 0 #fbb001 inset;
}

.carte-castors-filters h4 {
    margin: 0;
    padding: 0;
    color: #333;
    font-size: 16px;
    font-weight: bold;
}
.carte-castors-filters hr {
    margin: 6px 0;
}
.filter-group {
    margin-bottom: 15px;
}

.filter-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.filter-item:hover {
    background-color: rgba(0, 124, 186, 0.1);
}

.filter-item input[type="checkbox"] {
    margin-right: 8px;
    margin: 0 8px 0 0 !important;
    cursor: pointer;
}

.filter-marker {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.filter-label {
    font-size: 14px;
    color: #333;
    pointer-events: none;
}

.filter-count {
    background: #f0f0f0;
    color: white;
    font-size: 11px;
    padding: 3px 6px 2px 6px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    font-weight: 500;
    margin-left: 8px;
    color: #000;
    line-height: 1;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.carte-filter-all,
.carte-filter-none {
    flex: 1;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 12px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.carte-filter-all:hover {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.carte-filter-none:hover {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}


/* Couleurs des marqueurs */
.filter-marker.adherents {
    background-color: #2E7D32;
}

.filter-marker.chantiers {
    background-color: #D32F2F;
}

.filter-marker.events {
    background-color: #ffb100;
}

/* Système de Toast */
.carte-castors-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

.carte-castors-toast {
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    position: relative;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.carte-castors-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.carte-castors-toast.info {
    background: #007cba;
    border-left: 4px solid #005a87;
}

.carte-castors-toast.success {
    background: #28a745;
    border-left: 4px solid #1e7e34;
}

.carte-castors-toast.warning {
    background: #ffc107;
    color: #212529;
    border-left: 4px solid #e0a800;
}

.carte-castors-toast.error {
    background: #dc3545;
    border-left: 4px solid #bd2130;
}

.carte-castors-toast.debug {
    background: #6c757d;
    border-left: 4px solid #495057;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.carte-castors-toast .toast-close {
    position: absolute;
    padding: 0;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: inherit;
    font-size: 16px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.carte-castors-toast .toast-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.carte-castors-toast .toast-title {
    font-weight: bold;
    margin-bottom: 4px;
}

.carte-castors-toast .toast-content {
    padding-right: 25px;
}

/* Styles pour les popups avec clustering */
.maplibregl-popup-content {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0;
    max-width: 280px;
}

.popup-adherent,
.popup-chantier,
.popup-event {
    padding: 15px;
}

.popup-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 8px;
    color: #333;
    line-height: 1.3;
}

.popup-content {
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.4;
    color: #666;
}

.popup-meta {
    font-size: 12px;
    color: #888;
    margin-bottom: 10px;
    line-height: 1.4;
}

.popup-link {
    display: inline-block;
    background: #007cba;
    color: white;
    padding: 6px 12px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.popup-link:hover {
    background: #005a87;
    color: white;
}

/* Styles spécifiques pour les types */
.popup-adherent .popup-title {
    border-left: 4px solid #2E7D32;
    padding-left: 12px;
}

.popup-chantier .popup-title {
    border-left: 4px solid #D32F2F;
    padding-left: 12px;
}

.popup-event .popup-title {
    border-left: 4px solid #ffb100;
    padding-left: 12px;
}

.legend-marker.adherents {
    background-color: #2E7D32; /* Vert pour les adhérents */
}

.legend-marker.chantiers {
    background-color: #D32F2F; /* Rouge pour les chantiers participatifs */
}

.legend-marker.events {
    background-color: #ffb100; /* Bleu pour les autres événements */
}

/* Styles pour les popups MapLibre */
.maplibregl-popup-content {
    padding: 15px;
    max-width: 300px;
}

.popup-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
    font-size: 16px;
}

.popup-content {
    margin-bottom: 10px;
    color: #666;
    line-height: 1.4;
}

.popup-meta {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
}

.popup-link {
    display: inline-block;
    padding: 6px 12px;
    background-color: #2E7D32;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    transition: background-color 0.3s;
}

.popup-link:hover {
    background-color: #1B5E20;
    color: white;
}

.popup-adherent .popup-title {
    color: #2E7D32;
}

.popup-chantier .popup-title {
    color: #D32F2F;
}

.popup-event .popup-title {
    color: #ffb100;
}

/* Responsive */
@media (max-width: 768px) {
    .carte-castors-container {
        flex-direction: column;
    }
    
    .carte-castors-controls {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .carte-castors-filters,
    .carte-castors-legend {
        flex: 1;
        min-width: 280px;
    }
    
    .maplibregl-popup-content {
        max-width: 250px;
    }
}

/* Animation pour le chargement */
.carte-castors-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background-color: #f5f5f5;
    color: #666;
}

.carte-castors-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top: 2px solid #2E7D32;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

/* Styles responsives pour les filtres */
@media (max-width: 768px) {
    .carte-castors-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .carte-castors-map-wrapper {
        order: 1;
    }
    
    .carte-castors-map {
        min-height: 400px;
    }
    
    .carte-castors-controls {
        order: 2;
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        gap: 15px;
    }
    
    .carte-castors-filters {
        min-width: 250px;
        flex-shrink: 0;
    }
    
    .carte-castors-listing {
        min-width: 300px;
        height: 400px;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .carte-castors-container {
        flex-direction: column;
    }
    
    .carte-castors-map-wrapper {
        order: 1;
    }
    
    .carte-castors-map {
        min-height: 400px;
    }
    
    .carte-castors-controls {
        order: 2;
        flex-direction: column;
        width: 100%;
    }
    
    .carte-castors-filters,
    .carte-castors-listing {
        padding: 12px;
        width: 100%;
        min-width: auto;
    }
    
    .carte-castors-listing {
        height: 350px;
    }
    
    .filter-item {
        padding: 8px 4px;
    }
    
    .filter-label {
        font-size: 13px;
    }
    
    .filter-count {
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .listing-item-title {
        font-size: 13px;
    }
    
    .listing-item-meta {
        font-size: 11px;
    }
}

/* Message d'erreur */
.carte-castors-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef5350;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    font-weight: 500;
}

/* Styles pour les marqueurs DOM */
/* .carte-castors-marker {
    transition: transform 0.2s ease;
} */

.adherent-marker {
    background-color: #2E7D32 !important;
}

.chantier-marker {
    background-color: #D32F2F !important;
}

.event-marker {
    background-color: #ffb100 !important;
}

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

/* Styles pour les marqueurs décalés */
.carte-castors-offset-marker {
    position: relative;
}

.carte-castors-offset-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -100%);
    pointer-events: none;
    z-index: -1;
}

/* Indication visuelle pour les groupes de points */
.carte-castors-position-group {
    border: 2px dashed rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    pointer-events: none;
}

/* Styles pour les popups de points décalés */
.popup-offset-info {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.popup-offset-info::before {
    content: "ℹ️ ";
    margin-right: 4px;
}

/* Animation pour les marqueurs nouvellement décalés */
@keyframes offsetMarkerAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.carte-castors-offset-marker.new-offset {
    animation: offsetMarkerAppear 0.6s ease-out;
}

/* Styles pour le contrôle de géolocalisation */
.maplibregl-ctrl-geolocate {
    background-color: #fff;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: block;
    height: 29px;
    width: 29px;
    position: relative;
}

.maplibregl-ctrl-geolocate:hover {
    background-color: #f9f9f9;
    border-color: rgba(0, 0, 0, 0.3);
}

.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active {
    background-color: #7eaa01;
    border-color: #7eaa01;
}

.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active:hover {
    background-color: #6b9301;
    border-color: #6b9301;
}

.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting {
    background-color: #fcbe32;
    border-color: #fcbe32;
    animation: geolocateWaiting 1.5s infinite ease-in-out;
}

@keyframes geolocateWaiting {
    0%, 80%, 100% {
        opacity: 1;
    }
    40% {
        opacity: 0.6;
    }
}

/* Améliorer la visibilité du marqueur de position utilisateur */
.maplibregl-user-location-dot {
    background-color: #2876d2;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.3);
    height: 15px;
    width: 15px;
}

.maplibregl-user-location-accuracy-circle {
    background-color: rgba(25, 118, 210, 0.2);
    border: 1px solid rgba(25, 118, 210, 0.3);
    border-radius: 50%;
}

/* Styles pour la flèche de direction */
.maplibregl-user-location-heading {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 2l6 8-6 8-6-8z' fill='%23fff' stroke='%232876d2' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    height: 26px;
    width: 26px;
}
