/**
 * Carte des ventes - Styles Leaflet
 * Mobile first, layout 2 colonnes desktop
 */

.btpmat-sales-map {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Header */
.map-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e3f2fd;
}

.map-title {
    font-size: 24px;
    font-weight: 700;
    color: #1976d2;
    margin: 0 0 10px 0;
}

.map-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #546e7a;
}

.stat-item strong {
    color: #1976d2;
    font-size: 18px;
    font-weight: 700;
}

/* Layout 2 colonnes */
.map-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Wrapper carte Leaflet - colonne gauche */
.map-wrapper {
    position: relative;
    flex: 1;
    background: #f5f5f5;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Carte Leaflet */
#leaflet-map {
    width: 100%;
    height: 600px;
    border-radius: 12px;
    z-index: 1;
}

/* Légende - colonne droite */
.map-legend {
    flex-shrink: 0;
    width: 240px;
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.legend-title {
    font-weight: 700;
    font-size: 16px;
    color: #1976d2;
    margin-bottom: 15px;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #e3f2fd;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #546e7a;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.legend-item:hover {
    background: #f5f5f5;
}

/* Markers légende */
.legend-marker {
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff8c00 0%, #f27c00 100%);
    border: 2px solid #d66a00;
}

.legend-marker-small {
    width: 12px;
    height: 12px;
}

.legend-marker-medium {
    width: 16px;
    height: 16px;
}

.legend-marker-large {
    width: 20px;
    height: 20px;
}

/* Info légende */
.legend-info {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.legend-info p {
    margin: 8px 0;
    color: #757575;
    font-size: 12px;
    line-height: 1.4;
}

/* Personnalisation markers Leaflet */
.leaflet-marker-icon {
    border-radius: 50% !important;
}

/* Clusters Leaflet - style pro (orange) */
.marker-cluster-small {
    background-color: rgba(242, 124, 0, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(242, 124, 0, 0.8);
    color: white;
    font-weight: bold;
}

.marker-cluster-medium {
    background-color: rgba(255, 140, 0, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(255, 140, 0, 0.8);
    color: white;
    font-weight: bold;
}

.marker-cluster-large {
    background-color: rgba(214, 106, 0, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(214, 106, 0, 0.8);
    color: white;
    font-weight: bold;
}

/* Popup Leaflet personnalisée */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

.popup-info {
    min-width: 200px;
}

.popup-info h3 {
    margin: 0 0 10px 0;
    color: #1976d2;
    font-size: 16px;
    font-weight: 700;
    padding-bottom: 8px;
    border-bottom: 2px solid #e3f2fd;
}

.popup-info .info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.popup-info .info-label {
    font-weight: 600;
    color: #546e7a;
}

.popup-info .info-value {
    color: #212121;
    font-weight: 500;
}

.popup-info .info-value.highlight {
    color: #f27c00;
    font-weight: 700;
    font-size: 15px;
}

.popup-info .info-value.ref {
    font-family: 'Courier New', monospace;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

/* Responsive Mobile : empiler verticalement */
@media (max-width: 767px) {
    .map-content {
        flex-direction: column;
    }

    .map-legend {
        width: 100%;
        margin-top: 15px;
    }

    .legend-items {
        flex-direction: row;
        justify-content: space-around;
        flex-wrap: wrap;
    }

    #leaflet-map {
        height: 450px;
    }

    .legend-info {
        display: none; /* Masquer sur mobile pour gain de place */
    }
}

/* Responsive Tablet */
@media (min-width: 768px) {
    .btpmat-sales-map {
        padding: 25px;
    }

    .map-title {
        font-size: 32px;
    }

    .map-stats {
        font-size: 16px;
    }

    .stat-item strong {
        font-size: 22px;
    }

    #leaflet-map {
        height: 650px;
    }
}

/* Responsive Desktop */
@media (min-width: 1024px) {
    .btpmat-sales-map {
        padding: 30px;
    }

    .map-wrapper {
        border-radius: 16px;
    }

    #leaflet-map {
        height: 700px;
        border-radius: 16px;
    }

    .map-legend {
        width: 260px;
        padding: 25px;
    }

    .legend-title {
        font-size: 17px;
    }

    .legend-item {
        font-size: 15px;
    }
}

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

.leaflet-control-zoom a {
    border-radius: 4px !important;
    font-size: 18px !important;
    font-weight: bold !important;
}

.leaflet-control-zoom a:first-child {
    border-bottom: 1px solid #ccc !important;
}

/* Attribution Leaflet */
.leaflet-control-attribution {
    font-size: 10px !important;
    background: rgba(255, 255, 255, 0.8) !important;
}

/* Mode sombre (optionnel) */
@media (prefers-color-scheme: dark) {
    .btpmat-sales-map {
        color: #e0e0e0;
    }

    .map-header {
        border-bottom-color: #37474f;
    }

    .map-wrapper {
        background: #263238;
    }

    .map-legend {
        background: #37474f;
        color: #e0e0e0;
    }

    .legend-title {
        color: #64b5f6;
        border-bottom-color: #546e7a;
    }

    .legend-item {
        color: #b0bec5;
    }

    .legend-item:hover {
        background: #455a64;
    }

    .legend-info p {
        color: #90a4ae;
    }
}

/* Loading state */
.btpmat-sales-map.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btpmat-sales-map.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #e3f2fd;
    border-top-color: #1976d2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 9999;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}
