/* =======================================================
   STYLES POUR LES RÉGIONS - SOF
   ======================================================= */

/* Bouton mode d'affichage régional */
#toggle-region-mode {
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-left: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#toggle-region-mode:hover {
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    transform: translateY(-1px);
}

#toggle-region-mode.basemap-mode {
    background: linear-gradient(135deg, #f59e0b, #f97316);
}

#toggle-region-mode.basemap-mode:hover {
    background: linear-gradient(135deg, #d97706, #f59e0b);
}

/* Légende région */
#region-legend {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-size: 12px;
    min-width: 220px;
    z-index: 2000;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#region-legend h4 {
    margin: 0 0 8px 0;
    color: #ea580c;
    font-weight: 600;
    padding-bottom: 6px;
    border-bottom: 2px solid #fed7aa;
}

/* Mode légende fond de carte */
#region-legend.basemap-mode h4 {
    color: #f59e0b;
    border-bottom-color: #fef3c7;
}

#region-legend.basemap-mode .region-indicator {
    background-color: #f59e0b !important;
}

/* Styles pour le fond de carte régional */
.region-basemap {
    fill: rgba(254, 243, 199, 0.8) !important; /* Beige clair */
    stroke: #f59e0b !important; /* Orange */
    stroke-width: 2 !important;
    stroke-opacity: 0.9 !important;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.region-basemap:hover {
    fill: rgba(254, 243, 199, 0.9) !important;
    stroke-width: 3 !important;
}

/* Styles pour les contours de région */
.region-boundary {
    fill: rgba(249, 115, 22, 0.15);
    stroke: #ea580c;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.region-boundary:hover {
    fill: rgba(249, 115, 22, 0.25);
    stroke-width: 3;
    stroke-dasharray: none;
}

/* Popup région */
.region-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 0;
    border: 2px solid #ea580c;
}

/* Popup en mode fond de carte */
.region-popup.basemap-mode .leaflet-popup-content-wrapper {
    border-color: #f59e0b;
}

.region-popup-content {
    padding: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.region-popup-content h3 {
    margin: 0 0 12px 0;
    color: #ea580c;
    border-bottom: 2px solid #fed7aa;
    padding-bottom: 8px;
    font-weight: 600;
}

/* Titre popup en mode fond de carte */
.region-popup.basemap-mode .region-popup-content h3,
.region-popup.basemap-mode .region-popup-content h4 {
    color: #f59e0b;
}

.region-popup-content .stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 10px 0;
}

.region-popup-content .stat-item {
    background: #fef3c7;
    padding: 6px 8px;
    border-radius: 4px;
    text-align: center;
    border-left: 3px solid #f59e0b;
}

.region-popup-content .stat-number {
    font-size: 16px;
    font-weight: bold;
    color: #92400e;
}

.region-popup-content .stat-label {
    font-size: 10px;
    color: #a16207;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tooltip région */
.region-tooltip {
    background: rgba(234, 88, 12, 0.9) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    line-height: 1.3 !important;
}

.region-tooltip:before {
    border-top-color: rgba(234, 88, 12, 0.9) !important;
}

/* Loader région */
.region-loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    border: 2px solid #ea580c;
}

.region-loader .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #fed7aa;
    border-top: 2px solid #ea580c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.region-loader span {
    color: #ea580c;
    font-weight: 500;
    font-size: 14px;
}

/* Notification région */
.notification-region-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    border: none;
    animation: slideInRight 0.5s ease-out;
}

.notification-region-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    #region-legend {
        bottom: 80px;
        left: 5px;
        min-width: 200px;
        font-size: 11px;
    }
    
    #toggle-region {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .region-popup-content {
        max-width: 250px;
    }
    
    .region-popup-content .stat-grid {
        grid-template-columns: 1fr;
    }
}

/* Integration avec UTM */
.region-utm-info {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 6px;
    padding: 8px;
    margin-top: 10px;
    font-size: 11px;
}

.region-utm-info .utm-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.region-utm-info .utm-badge {
    background: #f59e0b;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 500;
}

/* Animation d'apparition */
.region-boundary-animated {
    animation: regionAppear 0.8s ease-out;
}

@keyframes regionAppear {
    from {
        opacity: 0;
        stroke-dashoffset: 20;
    }
    to {
        opacity: 1;
        stroke-dashoffset: 0;
    }
}
