/* ==================== STYLES CARTE LEAFLET ==================== */

/* Toggle Carte Container */
.map-toggle-container {
    background-color: var(--white-color);
    border-radius: 8px;
    padding: 1rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.map-toggle-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.map-toggle-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.map-toggle-icon {
    font-size: 2rem;
    line-height: 1;
}

.map-toggle-text h3 {
    color: var(--main-color);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.map-toggle-text p {
    color: var(--dark-light-color);
    font-size: 0.875rem;
    margin: 0;
}

/* Bouton Toggle Carte */
.btn-toggle-map {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background-color: var(--main-info-color);
    color: var(--white-color);
    border: none;
    border-radius: 6px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-toggle-map:hover {
    background-color: var(--main-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(53, 75, 207, 0.3);
}

.btn-toggle-map svg {
    width: 20px;
    height: 20px;
}

.btn-toggle-map.active {
    background-color: var(--main-danger-color);
}

.btn-toggle-map.active:hover {
    background-color: #C6212F;
}

/* Container Carte */
.map-container {
    background-color: var(--white-color);
    border-radius: 8px;
    padding: 0;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: none;
    height: 600px;
    position: relative;
}

.map-container.show {
    display: block;
    animation: slideDown 0.3s ease;
}

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

#map {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #f6fbff 0%, #eef5fb 100%);
}

/* Personnalisation contrôles Leaflet */
.leaflet-control-zoom {
    border: 2px solid var(--main-info-color) !important;
    border-radius: 6px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    color: var(--main-info-color) !important;
    font-weight: 700 !important;
}

.leaflet-control-zoom a:hover {
    background-color: var(--main-info-color) !important;
    color: var(--white-color) !important;
}

/* ==================== MARQUEURS PERSONNALISÉS ==================== */

/* Le wrapper doit être transparent : Leaflet.divIcon ajoute par défaut un fond + bordure */
.plu-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

/* Pin SVG moderne avec icône document à l'intérieur */
.plu-marker {
    position: relative;
    width: 36px;
    height: 46px;
    cursor: pointer;
    transform-origin: 50% 100%;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
    filter: drop-shadow(0 2px 4px rgba(14, 42, 76, 0.25));
}

.plu-marker svg {
    width: 100%;
    height: 100%;
    display: block;
}

.plu-marker .plu-marker-pin {
    fill: var(--main-info-color, #354BCF);
    stroke: var(--white-color, #ffffff);
    stroke-width: 2.5;
    transition: fill 0.2s ease;
}

.plu-marker .plu-marker-icon {
    fill: var(--white-color, #ffffff);
}

/* Hover : grossit, ombre plus marquée, couleur plus saturée */
.plu-marker:hover {
    transform: scale(1.18) translateY(-2px);
    filter: drop-shadow(0 6px 10px rgba(14, 42, 76, 0.4));
    z-index: 1000;
}

.plu-marker:hover .plu-marker-pin {
    fill: var(--main-color, #1d2a8a);
}

/* État actif (marker sélectionné via popup ouvert) : pulse continu */
.plu-marker.is-active {
    transform: scale(1.22) translateY(-2px);
    filter: drop-shadow(0 8px 14px rgba(206, 31, 47, 0.45));
    z-index: 1001;
}

.plu-marker.is-active .plu-marker-pin {
    fill: var(--main-danger-color, #CE1F2F);
}

/* Halo pulsant sous le marker actif */
.plu-marker.is-active::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 6px;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--main-danger-color, #CE1F2F);
    opacity: 0.45;
    animation: pluPulse 1.6s ease-out infinite;
    z-index: -1;
}

@keyframes pluPulse {
    0% {
        transform: translateX(-50%) scale(0.6);
        opacity: 0.55;
    }
    80% {
        transform: translateX(-50%) scale(2.2);
        opacity: 0;
    }
    100% {
        transform: translateX(-50%) scale(2.2);
        opacity: 0;
    }
}

/* Animation d'apparition légère quand le marker est ajouté */
.plu-marker-drop {
    animation: pluDrop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pluDrop {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.6);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==================== TOOLTIP HOVER ==================== */
.plu-marker-tooltip.leaflet-tooltip {
    background: rgba(14, 31, 50, 0.95);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plu-marker-tooltip.leaflet-tooltip::before {
    border-top-color: rgba(14, 31, 50, 0.95) !important;
}

.plu-marker-tooltip.leaflet-tooltip-top::before {
    border-top-color: rgba(14, 31, 50, 0.95) !important;
}

/* ==================== CLUSTERS ==================== */
/* On reskin les clusters Leaflet.markercluster avec la charte Paris.fr */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: transparent !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: transparent !important;
    color: #fff !important;
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
}

.plu-cluster {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(14, 42, 76, 0.35);
    border: 3px solid #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.plu-cluster::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.25;
    z-index: -1;
}

.plu-cluster:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(14, 42, 76, 0.5);
}

.plu-cluster.cluster-sm {
    background: linear-gradient(135deg, #5870e0 0%, #354BCF 100%);
    width: 36px !important;
    height: 36px !important;
    font-size: 0.85rem;
}

.plu-cluster.cluster-md {
    background: linear-gradient(135deg, #354BCF 0%, #1d2a8a 100%);
    width: 44px !important;
    height: 44px !important;
    font-size: 0.95rem;
}

.plu-cluster.cluster-lg {
    background: linear-gradient(135deg, #CE1F2F 0%, #8a0d1a 100%);
    width: 52px !important;
    height: 52px !important;
    font-size: 1.05rem;
}

/* ==================== POPUP MARKER ==================== */
.leaflet-popup-content-wrapper {
    border-radius: 14px !important;
    box-shadow: 0 12px 36px rgba(14, 42, 76, 0.22), 0 0 0 1px rgba(15, 76, 129, 0.06) !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-tip {
    box-shadow: 0 6px 20px rgba(14, 42, 76, 0.18) !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    min-width: 280px;
    max-width: 320px;
}

.leaflet-popup-close-button {
    width: 28px !important;
    height: 28px !important;
    font-size: 22px !important;
    line-height: 26px !important;
    color: #fff !important;
    background: rgba(14, 31, 50, 0.55) !important;
    border-radius: 50% !important;
    top: 8px !important;
    right: 8px !important;
    text-align: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.leaflet-popup-close-button:hover {
    background: rgba(206, 31, 47, 0.9) !important;
    transform: scale(1.1);
}

.marker-popup {
    padding: 0;
}

.marker-popup-thumb-wrap {
    position: relative;
    background: linear-gradient(180deg, #edf3fa 0%, #dbe6f3 100%);
    height: 140px;
    overflow: hidden;
}

.marker-popup-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.marker-popup-thumb-wrap:hover .marker-popup-thumb {
    transform: scale(1.05);
}

.marker-popup-thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(14, 31, 50, 0.7) 100%);
    pointer-events: none;
}

.marker-popup-body {
    padding: 0.95rem 1rem 1rem;
}

.marker-popup-title {
    font-weight: 700;
    color: var(--main-color);
    margin-bottom: 0.4rem;
    font-size: 0.98rem;
    line-height: 1.35;
    word-break: break-word;
}

.marker-popup-description {
    color: var(--dark-light-color);
    font-size: 0.82rem;
    margin-bottom: 0.85rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.marker-popup-description:empty {
    display: none;
}

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

.marker-popup-btn {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.marker-popup-btn svg {
    width: 16px;
    height: 16px;
}

.marker-popup-btn.primary {
    background-color: var(--main-info-color);
    color: var(--white-color);
    box-shadow: 0 3px 10px rgba(53, 75, 207, 0.35);
}

.marker-popup-btn.primary:hover {
    background-color: var(--main-color);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(53, 75, 207, 0.45);
}

.marker-popup-btn.secondary {
    background-color: var(--white-color);
    color: var(--main-info-color);
    border: 2px solid var(--main-info-color);
}

.marker-popup-btn.secondary:hover {
    background-color: var(--main-info-color);
    color: var(--white-color);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(53, 75, 207, 0.35);
}

/* Stats sur la carte */
.map-stats {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.97);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(14, 42, 76, 0.18);
    border: 1px solid rgba(15, 76, 129, 0.12);
    z-index: 1000;
    min-width: 200px;
}

.map-stats h4 {
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--main-color);
}

.map-stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-lighter-color);
    font-size: 0.875rem;
}

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

.map-stat-label {
    color: var(--dark-light-color);
}

.map-stat-value {
    color: var(--main-info-color);
    font-weight: 700;
}

/* Loading carte */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 999;
}

.map-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-light-color);
    border-top: 4px solid var(--main-info-color);
    border-radius: 50%;
    animation: mapSpin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Responsive carte */
@media (max-width: 768px) {
    .map-toggle-container {
        flex-direction: column;
        gap: 1rem;
    }

    .btn-toggle-map {
        width: 100%;
        justify-content: center;
    }

    .map-container {
        height: 400px;
    }

    .map-stats {
        top: 5px;
        right: 5px;
        min-width: 150px;
        padding: 0.75rem;
    }
}