/* Leaflet CSS overrides and custom map styles */

/* Map wrapper - ensure low z-index so header menu appears above */
.szm-map-wrapper {
    position: relative;
    z-index: 0;
}

/* Map container */
#szm-map-container,
#szm-map-container-departements,
#szm-map-container-region {
    height: 100%;
    min-height: 500px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
    position: relative;
    z-index: 0;
}

/* Custom tooltip styling */
.szm-map-tooltip {
    background: rgba(0, 0, 0, 0.85) !important;
    border: none !important;
    border-radius: 8px !important;
    color: white !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    padding: 10px 16px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    letter-spacing: 0.3px;
}

.szm-map-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.85) !important;
}

/* Leaflet zoom controls styling */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-control-zoom a {
    background: white !important;
    color: #333 !important;
    font-size: 20px !important;
    line-height: 32px !important;
    width: 36px !important;
    height: 36px !important;
    border: none !important;
    transition: all 0.2s ease !important;
}

.leaflet-control-zoom a:hover {
    background: #f0f0f0 !important;
    color: var(--szm-primary) !important;
}

.leaflet-control-zoom-in {
    border-radius: 8px 8px 0 0 !important;
}

.leaflet-control-zoom-out {
    border-radius: 0 0 8px 8px !important;
}

/* Leaflet attribution */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    font-size: 11px !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
}

/* Map loading state */
#szm-map-container.loading {
    position: relative;
}

#szm-map-container.loading::after {
    content: 'Chargement de la carte...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 16px;
    color: #333;
    z-index: 500;
}

/* Force Leaflet panes inside our wrapper to sit behind site chrome */
.szm-map-wrapper .leaflet-container,
.szm-map-wrapper .leaflet-map-pane,
.szm-map-wrapper .leaflet-tile-pane,
.szm-map-wrapper .leaflet-overlay-pane,
.szm-map-wrapper .leaflet-shadow-pane,
.szm-map-wrapper .leaflet-marker-pane,
.szm-map-wrapper .leaflet-popup-pane,
.szm-map-wrapper .leaflet-tooltip-pane {
    z-index: 0 !important;
}

/* Region polygon styling enhancements */
.leaflet-interactive {
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Department labels */
.department-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none;
    /* Centre le label sur le marker */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.department-label .label-content {
    background: rgba(37, 99, 235, 0.95);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.3px;
    line-height: 1.2;
    /* Centre le texte dans la boîte */
    text-align: center;
    /* Transforme pour centrer parfaitement */
    transform: translate(-50%, -50%);
    position: relative;
    left: 50%;
    top: 50%;
}

/* City markers (blue dots) */
.city-marker {
    background: #3b82f6 !important;
    border: 2px solid #1d4ed8 !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.5) !important;
    cursor: pointer !important;
}

.city-marker:hover {
    background: #2563eb !important;
    border-color: #1e40af !important;
}

/* Villes list */
.szm-villes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.szm-ville-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
}

.szm-ville-item:hover {
    background: #e3f2fd;
    border-color: #2563eb;
    transform: translateX(4px);
}

.szm-ville-content {
    flex: 1;
}

.szm-ville-name {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.szm-ville-dept {
    font-size: 13px;
    color: #666;
}

.szm-ville-distance {
    font-size: 14px;
    font-weight: 600;
    color: #2563eb;
    background: #e3f2fd;
    padding: 6px 14px;
    border-radius: 12px;
    white-space: nowrap;
    margin-left: 12px;
}

.szm-ville-link {
    color: #2563eb;
    font-size: 13px;
    white-space: nowrap;
}

.szm-ville-item:hover .szm-ville-link {
    text-decoration: underline;
}

/* Regions list */
.szm-region-item {
    display: block;
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-align: left;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.szm-region-item:hover {
    background: #e3f2fd;
    border-color: #2563eb;
    color: #2563eb;
    transform: translateX(4px);
}

.szm-region-item:active {
    transform: translateX(2px);
}

/* Map section wrapper */
.szm-map-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* France map specific container */
#szm-map-container-france {
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafb;
    min-height: 420px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

#szm-map-container-france.szm-map-fade-in {
    animation: szm-fade-in 0.28s ease both;
}

@keyframes szm-fade-in {
    from { opacity: 0; transform: translateY(6px) scale(0.998); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tweak tooltip for France map */
.szm-map-tooltip {
    font-size: 13px !important;
    padding: 8px 12px !important;
}

/* Subtle highlight when hovering region items (sidebar) */
.szm-region-item {
    cursor: pointer;
}

/* Make the Leaflet zoom control match the design */
.szm-map-wrapper .leaflet-control-zoom {
    right: 12px !important;
    top: 12px !important;
}

/* Responsive map */
@media (max-width: 768px) {
    #szm-map-container {
        min-height: 400px;
        border-radius: 8px;
    }
    
    .szm-map-section {
        padding: 12px;
        height: auto;
    }
}

@media (max-width: 480px) {
    #szm-map-container {
        min-height: 350px;
    }
    
    .szm-map-tooltip {
        font-size: 12px !important;
        padding: 8px 12px !important;
    }
}

/* Modal pour demande de sélection de nuisible */
.szm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.szm-modal.active {
    opacity: 1;
    pointer-events: all;
}

.szm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.szm-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 40px 32px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: szm-modal-enter 0.3s ease;
    transform-origin: center;
}

@keyframes szm-modal-enter {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.szm-modal-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: szm-icon-bounce 0.6s ease;
}

@keyframes szm-icon-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.szm-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 16px;
    line-height: 1.3;
}

.szm-modal-message {
    font-size: 16px;
    color: #64748b;
    line-height: 1.6;
    margin: 0 0 32px;
}

.szm-modal-select {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    margin: 0 0 20px;
}

.szm-modal-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff !important;
    border: none !important;
    outline: none;
    border-radius: 10px;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.szm-modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    color: #ffffff !important;
}

.szm-modal-btn:active {
    transform: translateY(0);

    color: #ffffff !important;
}

/* Animation pulse pour le select */
@keyframes szm-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(37, 99, 235, 0);
    }
}

/* Autocomplete avec distances */
.szm-autocomplete-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
}

.szm-autocomplete-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.szm-autocomplete-distance {
    font-size: 13px;
    font-weight: 600;
    color: #2563eb;
    background: #e3f2fd;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

/* Marqueur utilisateur */
.szm-user-marker {
    background: transparent;
    border: none;
}

.szm-user-marker-inner {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    animation: szm-user-pulse 2s infinite;
}

@keyframes szm-user-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* Menu stays at default z-index (will be above map) */
.wp-block-navigation__submenu-container {
    z-index: auto !important;
}

.wp-block-navigation {
    z-index: auto !important;
}

header,
.header,
nav,
.navbar,
.navigation,
.menu,
.menu-dropdown,
[role="menu"],
.dropdown-menu,
.site-header,
.wp-block-navigation__responsive-container {
    z-index: auto !important;
}

/* Ensure modal stays on top */
.szm-modal {
    z-index: 10000 !important;
}
