/* ========================================
   CARTE PROFESSIONNELLE - STYLES PREMIUM
   Dark Mode, Side Panel, Clustering, Animations
   ======================================== */

/* ========== VARIABLES ========== */
:root {
    --panel-width: 380px;
    --panel-bg: #1e293b;
    --panel-text: #e5e7eb;
    --panel-border: rgba(255, 255, 255, 0.1);
    --map-bg: #0f172a;
    --accent-color: #18ABF8;
    --success-color: #059669;
    --warning-color: #f59e0b;
    --danger-color: #dc2626;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ========== MAIN CONTENT ========== */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

.carte-container {
    position: relative;
    height: 600px;
    min-height: 600px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* ========== FILTRES SECTION ========== */
.filtres-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.filtres-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filtre-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filtre-group label {
    color: #374151;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filtre-group label i {
    color: var(--accent-color);
}

.filtre-group select {
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    color: #1f2937;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filtre-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(24, 171, 248, 0.1);
}

.btn-reset {
    padding: 0.75rem 1.5rem;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    align-self: flex-end;
}

.btn-reset:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* ========== MAP WRAPPER ========== */
.map-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 600px;
}

#map-pro {
    width: 100%;
    height: 100%;
    min-height: 600px;
    position: absolute;
    top: 0;
    left: 0;
}

/* ========== FLOATING LEGEND ========== */
.floating-legend {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    min-width: 220px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--panel-border);
}

.legend-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-header h3 i {
    color: var(--accent-color);
}

.btn-minimize {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-minimize:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.floating-legend.minimized .legend-content {
    display: none;
}

.floating-legend.minimized .btn-minimize i::before {
    content: "\f067"; /* fa-plus */
}

.legend-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.legend-checkbox-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.legend-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.legend-checkbox-item .legend-marker {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.legend-label {
    font-size: 0.9rem;
    color: var(--panel-text);
    font-weight: 500;
}

.legend-checkbox-item input[type="checkbox"]:not(:checked) + .legend-marker {
    opacity: 0.3;
    filter: grayscale(1);
}

.legend-checkbox-item input[type="checkbox"]:not(:checked) ~ .legend-label {
    opacity: 0.5;
    text-decoration: line-through;
}

/* ========== CUSTOM MAP CONTROLS ========== */
.custom-controls {
    position: absolute;
    bottom: 5rem;
    left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 999;
}

.control-btn {
    width: 48px;
    height: 48px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

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

.control-btn:active {
    transform: scale(0.95);
}

/* ========== MAP STATISTICS ========== */
.map-stats {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    display: flex;
    gap: 2rem;
    box-shadow: var(--shadow-lg);
    z-index: 999;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--panel-text);
}

.stat-item i {
    color: var(--accent-color);
    font-size: 1rem;
}

.stat-item strong {
    color: white;
    font-weight: 700;
}

/* ========== MAPBOX GL MARKERS ========== */
/* Marqueurs circulaires personnalisés */
.custom-marker-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    font-size: 18px;
    transform-origin: center center;
}

.custom-marker-circle:hover {
    transform: scale(1.15);
    z-index: 10;
}


/* ========== PREMIUM POPUP STYLING ========== */
.mapboxgl-popup-content {
    background: var(--panel-bg) !important;
    color: var(--panel-text) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--panel-border) !important;
    padding: 0 !important;
}

.mapboxgl-popup-tip {
    border-top-color: var(--panel-bg) !important;
    border-bottom-color: var(--panel-bg) !important;
}

.mapboxgl-popup-close-button {
    color: white !important;
    font-size: 20px !important;
    padding: 5px 10px !important;
}

.mapboxgl-popup-close-button:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.premium-popup {
    min-width: 280px;
}

.popup-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 12px 12px 0 0;
}

.popup-content {
    padding: 1rem;
}

.popup-category {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.75rem;
}

.popup-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.popup-description {
    font-size: 0.9rem;
    color: #94a3b8;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.popup-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 1rem 0;
    border-top: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 1rem;
}

.popup-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.popup-meta-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.popup-meta-value {
    font-size: 0.95rem;
    color: white;
    font-weight: 600;
}

.popup-progress {
    margin-bottom: 1rem;
}

.popup-progress-label {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #10b981);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.popup-footer {
    display: flex;
    gap: 0.5rem;
}

.popup-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.popup-btn-primary:hover {
    background: #1594d6;
    transform: translateY(-1px);
}

.popup-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--panel-text);
    border: 1px solid var(--panel-border);
}

.popup-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Marker cluster styling moved to "MAPBOX GL MARKERS" section above */

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 1024px) {
    .main-content {
        padding: 1.5rem;
    }

    .filtres-grid {
        grid-template-columns: 1fr 1fr;
    }

    .btn-reset {
        grid-column: span 2;
    }

    .map-stats {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        bottom: 0.5rem;
    }

    .floating-legend {
        top: auto;
        bottom: 5rem;
        right: 0.5rem;
    }

    .custom-controls {
        bottom: 0.5rem;
        left: 0.5rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .filtres-grid {
        grid-template-columns: 1fr;
    }

    .btn-reset {
        grid-column: 1;
    }

    .carte-container {
        height: 500px;
    }

    .map-stats {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    .floating-legend {
        min-width: auto;
        max-width: 200px;
    }

    .control-btn {
        width: 40px;
        height: 40px;
    }
}

/* ========== ANIMATIONS ========== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.loading {
    animation: pulse 2s infinite;
}

/* ========== MAPBOX TILES ========== */
/* Les tuiles Mapbox sont déjà stylisées (satellite-streets-v12, light-v11) */
/* Pas besoin de filtres CSS supplémentaires */

/* ========== MARKER CLUSTERING STYLES ========== */
/* Styles pour les clusters de marqueurs (Supercluster) */

.marker-cluster {
    background: linear-gradient(135deg, #18ABF8, #0891b2);
    border: 3px solid white;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.marker-cluster:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 20px rgba(24, 171, 248, 0.6);
    z-index: 1000;
}

.marker-cluster:active {
    transform: scale(1.05);
}

/* Animation d'apparition des clusters */
@keyframes clusterAppear {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.marker-cluster {
    animation: clusterAppear 0.3s ease-out;
}

/* ========== MARQUEURS DOM AVEC IMAGES PNG ========== */
.marker-dom {
    cursor: pointer;
    position: relative;
}

.marker-dom .marker-img {
    width: 42px;
    height: 42px;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

.marker-dom:hover .marker-img {
    transform: scale(1.25);
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.4));
}

/* Badge numérique pour les marqueurs groupés */
.marker-dom .marker-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #18ABF8;
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ========== MARQUEURS CLUSTER AVEC SUPERCLUSTER ========== */
.marker-cluster-custom {
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster-custom .cluster-icon {
    width: 48px;
    height: 48px;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

.marker-cluster-custom.hovered .cluster-icon {
    transform: scale(1.2);
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.4));
}

.marker-cluster-custom .cluster-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #18ABF8;
    color: white;
    font-size: 12px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Marqueur individuel */
.marker-single {
    cursor: pointer;
}

.marker-single .single-icon {
    width: 42px;
    height: 42px;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

.marker-single.hovered .single-icon {
    transform: scale(1.2);
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.4));
}

/* ========== POPUP CLUSTER LISTE ========== */
.popup-cluster {
    padding: 0;
}

.popup-cluster h3 {
    margin: 0 0 12px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 16px;
    color: #1f2937;
}

.popup-cluster h3 i {
    color: #18ABF8;
    margin-right: 8px;
}

.cluster-list {
    max-height: 250px;
    overflow-y: auto;
}

.cluster-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cluster-list-item:hover {
    background: #f3f4f6;
}

.cluster-list-item .list-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.cluster-list-item .list-info {
    flex: 1;
    min-width: 0;
}

.cluster-list-item .list-info strong {
    display: block;
    font-size: 13px;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cluster-list-item .list-info small {
    color: #6b7280;
    font-size: 11px;
}

/* ========== BADGE GROUPE SUPERPOSÉ ========== */
.group-badge-marker {
    cursor: pointer;
    z-index: 10;
}

.group-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #18ABF8;
    color: white;
    font-size: 12px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.group-badge-marker:hover .group-badge {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
