/* leaflet-custom.css */
/* Styles personnalisés pour les cartes Leaflet - VendsMonBien */

/* ===========================================
   STYLES COMMUNS À TOUTES LES CARTES
   =========================================== */

/* Conteneur carte générique */
#map,
.map-container,
#map-comparables,
#map-pros,
#agents-map,
#locationMap {
    width: 100%;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    z-index: 1;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

#map {
    height: 600px;
}

/* Marqueurs propriétés */
.property-marker {
    font-size: 24px;
    text-align: center;
    line-height: 30px;
    background: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid #3b82f6;
    cursor: pointer;
    transition: transform 0.2s;
}

.property-marker:hover {
    transform: scale(1.2);
    z-index: 1000;
}

/* Marqueur centre draggable */
.center-marker {
    font-size: 30px;
    text-align: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    cursor: move;
}

/* Clusters */
.marker-cluster {
    background: transparent;
}

.cluster-icon {
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border: 3px solid white;
    transition: transform 0.2s;
}

.cluster-icon:hover {
    transform: scale(1.1);
}

.cluster-medium {
    background: #f59e0b;
    width: 50px;
    height: 50px;
    font-size: 16px;
}

.cluster-large {
    background: #ef4444;
    width: 60px;
    height: 60px;
    font-size: 18px;
}

/* Popups propriété */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

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

.property-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.popup-photo {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.popup-no-photo {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, #FF6E14 0%, #e56312 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
}

.popup-content {
    padding: 16px;
}

.popup-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.popup-address {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 12px 0;
}

.popup-prix {
    font-size: 20px;
    font-weight: 700;
    color: #3b82f6;
    margin: 0 0 8px 0;
}

.popup-detail {
    font-size: 13px;
    color: #4b5563;
    margin: 4px 0;
}

.popup-distance {
    font-size: 12px;
    color: #9ca3af;
    margin: 8px 0 12px 0;
}

.dpe-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: white;
    margin: 8px 0;
}

.dpe-A { background: #00a550; }
.dpe-B { background: #51b935; }
.dpe-C { background: #c3d700; }
.dpe-D { background: #fff200; color: #333; }
.dpe-E { background: #f39200; }
.dpe-F { background: #ed1c24; }
.dpe-G { background: #d71e00; }

.popup-link {
    display: inline-block;
    background: #3b82f6;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    margin-top: 8px;
    text-align: center;
    width: 100%;
}

.popup-link:hover {
    background: #2563eb;
    text-decoration: none;
    color: white;
}

/* Contrôles carte */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.leaflet-control-zoom a {
    background: white;
    color: #374151;
    border-radius: 8px;
    margin: 4px;
    width: 36px;
    height: 36px;
    line-height: 36px;
    font-size: 20px;
    font-weight: bold;
    border: 2px solid #e5e7eb;
    transition: all 0.2s;
}

.leaflet-control-zoom a:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Slider rayon */
#radius-slider {
    width: 200px;
    accent-color: #3b82f6;
}

/* Toggle vue liste/carte */
#toggle-view {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;  /* Sous le header (1001) */
    background: white;
    border: 2px solid #3b82f6;
    color: #3b82f6;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s;
}

#toggle-view:hover {
    background: #3b82f6;
    color: white;
    transform: scale(1.05);
}

/* Compteur résultats */
#results-count {
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    display: inline-block;
}

/* Bouton géolocalisation */
#geolocate-btn {
    background: white;
    border: 2px solid #10b981;
    color: #10b981;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#geolocate-btn:hover {
    background: #10b981;
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    #map {
        height: 400px;
        border-radius: 8px;
    }

    .leaflet-popup-content {
        width: 240px !important;
    }

    .popup-photo {
        height: 120px;
    }

    #radius-slider {
        width: 150px;
    }

    #toggle-view {
        bottom: 10px;
        right: 10px;
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Animation chargement */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    border-radius: 12px;
}

.loading-spinner {
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* ===========================================
   MARQUEURS MODERNES
   =========================================== */

/* Marqueur principal du bien */
.marker-bien {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #FF6E14 0%, #e56312 100%);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    border: 3px solid white;
    animation: bounce-in 0.5s ease-out;
}

.marker-bien::after {
    content: '🏠';
    font-size: 20px;
    transform: rotate(45deg);
}

/* Marqueur transaction comparable */
.marker-comparable {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.35);
    border: 2px solid white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: white;
    font-weight: 700;
}

.marker-comparable:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

/* Marqueur professionnel/agent */
.marker-pro,
.marker-agent {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(59, 130, 246, 0.4);
    border: 2px solid white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.marker-pro:hover,
.marker-agent:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.marker-pro::after,
.marker-agent::after {
    content: '👤';
    font-size: 18px;
}

/* Animation d'entrée */
@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: rotate(-45deg) scale(0.3);
    }
    50% {
        transform: rotate(-45deg) scale(1.05);
    }
    70% {
        transform: rotate(-45deg) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: rotate(-45deg) scale(1);
    }
}

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

/* ===========================================
   POPUPS MODERNES
   =========================================== */

/* Override Leaflet popup */
.leaflet-popup {
    animation: fade-in-up 0.3s ease-out;
}

.leaflet-popup-content-wrapper {
    border-radius: 16px !important;
    padding: 0 !important;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.leaflet-popup-content {
    margin: 0 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.leaflet-popup-tip {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.leaflet-popup-close-button {
    top: 8px !important;
    right: 8px !important;
    width: 28px !important;
    height: 28px !important;
    font-size: 18px !important;
    color: #6b7280 !important;
    background: white !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.leaflet-popup-close-button:hover {
    color: #1f2937 !important;
    background: #f3f4f6 !important;
}

/* Popup transaction comparable */
.popup-comparable {
    min-width: 260px;
    padding: 20px;
}

.popup-comparable-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.popup-comparable-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #FF6E14 0%, #e55a00 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.popup-comparable-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.popup-comparable-date {
    font-size: 12px;
    color: #9ca3af;
    margin: 2px 0 0 0;
}

.popup-comparable-price {
    font-size: 24px;
    font-weight: 700;
    color: #10b981;
    margin: 0 0 4px 0;
}

.popup-comparable-price-m2 {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 16px 0;
}

.popup-comparable-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.popup-comparable-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.popup-comparable-detail-label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-comparable-detail-value {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

/* Popup professionnel/agent */
.popup-agent {
    min-width: 280px;
    padding: 0;
}

.popup-agent-header {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    padding: 20px;
    color: white;
}

.popup-agent-name {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px 0;
}

.popup-agent-role {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;
}

.popup-agent-body {
    padding: 16px 20px;
}

.popup-agent-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #4b5563;
}

.popup-agent-info-icon {
    width: 32px;
    height: 32px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.popup-agent-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    margin-top: 12px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.popup-agent-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    color: white;
    text-decoration: none;
}

/* ===========================================
   CONTRÔLES MODERNES
   =========================================== */

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    border-radius: 12px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: white !important;
    color: #374151 !important;
    border: none !important;
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    font-size: 18px !important;
    font-weight: 600;
    transition: all 0.2s;
}

.leaflet-control-zoom a:first-child {
    border-radius: 12px 12px 0 0 !important;
}

.leaflet-control-zoom a:last-child {
    border-radius: 0 0 12px 12px !important;
}

.leaflet-control-zoom a:hover {
    background: #3b82f6 !important;
    color: white !important;
}

.leaflet-control-zoom-in {
    border-bottom: 1px solid #e5e7eb !important;
}

/* Attribution masquée */
.leaflet-control-attribution {
    display: none !important;
}

/* ===========================================
   BOUTON RECENTRAGE
   =========================================== */

.map-recenter-btn {
    position: absolute;
    top: 80px;
    right: 10px;
    z-index: 100;  /* Sous le header (1001) */
    width: 40px;
    height: 40px;
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.map-recenter-btn:hover {
    background: #FF6E14;
    color: white;
    transform: scale(1.05);
}

.map-recenter-btn:hover svg {
    stroke: white;
}

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

.map-recenter-btn.recentering {
    animation: pulse-recenter 0.6s ease-out;
}

@keyframes pulse-recenter {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); background: #FF6E14; color: white; }
    100% { transform: scale(1); }
}

/* ===========================================
   LÉGENDE DE CARTE
   =========================================== */

.map-legend {
    position: absolute;
    bottom: 30px;
    left: 10px;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;  /* Sous le header (1001) */
    font-size: 12px;
}

.map-legend-title {
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.map-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.map-legend-item:last-child {
    margin-bottom: 0;
}

.map-legend-marker {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.map-legend-marker--bien {
    background: linear-gradient(135deg, #FF6E14 0%, #e56312 100%);
}

.map-legend-marker--comparable {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.map-legend-marker--agent {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
    .popup-comparable {
        min-width: 220px;
        padding: 16px;
    }

    .popup-comparable-price {
        font-size: 20px;
    }

    .popup-agent {
        min-width: 240px;
    }

    .map-legend {
        bottom: 20px;
        left: 8px;
        padding: 10px 12px;
        font-size: 11px;
    }
}

/* ===========================================
   STYLE MODERNE DES TUILES DE CARTE
   =========================================== */

/* Appliquer des filtres pour un rendu plus moderne et épuré */
.leaflet-tile-pane {
    filter: saturate(0.85) contrast(1.02) brightness(1.01);
}

/* Effet de fondu sur le chargement des tuiles */
.leaflet-tile {
    transition: opacity 0.3s ease-in-out;
}

/* Bordure subtile autour des conteneurs de carte */
.leaflet-container {
    background: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Style moderne pour le cercle de localisation approximative */
.leaflet-interactive.leaflet-circle {
    stroke-linecap: round;
}

/* ===========================================
   MARQUEURS CARTE DES ANNONCES
   =========================================== */

/* Marqueurs annonces : utilise L.icon (img) — pas de CSS transform nécessaire */

/* ===========================================
   POPUP CARTE DES ANNONCES (AMÉLIORÉ)
   =========================================== */

.annonces-map-popup .leaflet-popup-content-wrapper {
    border-radius: 16px !important;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 20px 25px -5px rgba(0, 0, 0, 0.1) !important;
    border: none;
    overflow: hidden;
}

.annonces-map-popup .leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
}

.annonces-map-popup .leaflet-popup-tip-container {
    margin-top: -1px;
}

.annonces-map-popup .leaflet-popup-tip {
    background: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* ===========================================
   EFFETS DE SURVOL ET TRANSITIONS
   =========================================== */

/* Effet de survol sur les contrôles de zoom */
.leaflet-control-zoom {
    transition: box-shadow 0.2s ease;
}

.leaflet-control-zoom:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
}

/* Ne PAS mettre de transition/transform sur .leaflet-marker-icon. */

/* ===========================================
   STYLE POI (POINTS D'INTÉRÊT)
   =========================================== */

.poi-marker > div {
    transition: transform 0.2s ease;
}

.poi-marker:hover > div {
    transform: scale(1.3);
}

/* Style des popups POI */
.poi-marker .leaflet-popup-content-wrapper {
    border-radius: 10px !important;
    padding: 0 !important;
}

/* ===========================================
   MODE SOMBRE (PRÉPARATION)
   =========================================== */

@media (prefers-color-scheme: dark) {
    .leaflet-tile-pane {
        filter: saturate(0.8) contrast(1.05) brightness(0.95) invert(1) hue-rotate(180deg);
    }

    .leaflet-marker-icon,
    .leaflet-popup-content-wrapper,
    .leaflet-control-zoom,
    .map-recenter-btn {
        filter: none;
    }
}
