/**
 * Map shortcode [cmci_carte] styles (Leaflet map + popups).
 *
 * Class-scoped, enqueued as a stylesheet instead of an inline <style> block.
 *
 * @package ChaletMontagne
 * @since   1.0.61
 */

/* Map component styles - scoped to this instance */
.cmv2-carte {
    margin: 1.5rem 0;
}

.cmv2-carte .cmv2-carte__title.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.cmv2-carte .cmv2-carte__empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: #666;
    background: #f8f9fa;
    border-radius: 8px;
}

.cmv2-carte .cmv2-carte__empty p {
    margin: 0;
    font-size: 1rem;
}

/* Map container */
.cmv2-carte .cmv2-carte__container {
    position: relative;
    width: 100%;
    min-height: 300px;
    border-radius: 8px;
    overflow: hidden;
    background: #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cmv2-carte .cmv2-carte__container:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* Loading indicator */
.cmv2-carte .cmv2-carte__loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
}

.cmv2-carte.is-loaded .cmv2-carte__loader {
    display: none;
}

.cmv2-carte .cmv2-carte__spinner {
    display: block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(52, 152, 219, 0.2);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: cmv2-carte-spin 0.8s linear infinite;
}

@keyframes cmv2-carte-spin {
    to {
        transform: rotate(360deg);
    }
}

.cmv2-carte .cmv2-carte__loading-text {
    font-size: 0.875rem;
    color: #666;
}

/* Legend */
.cmv2-carte .cmv2-carte__legend {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cmv2-carte .cmv2-carte__legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cmv2-carte .cmv2-carte__marker-icon {
    color: #e74c3c;
}

/* =========================================================================
   Leaflet Popup Customization
   ========================================================================= */

.cmv2-carte .cmv2-popup {
    min-width: 220px;
    max-width: 300px;
}

.cmv2-carte .cmv2-popup__photo {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 4px 4px 0 0;
    margin: -14px -20px 12px -20px;
    width: calc(100% + 40px);
    max-width: calc(100% + 40px);
}

.cmv2-carte .cmv2-popup__title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.cmv2-carte .cmv2-popup__details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    color: #666;
}

.cmv2-carte .cmv2-popup__detail {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cmv2-carte .cmv2-popup__detail svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.cmv2-carte .cmv2-popup__link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: #3498db;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.cmv2-carte .cmv2-popup__link:hover,
.cmv2-carte .cmv2-popup__link:focus {
    background: #2980b9;
    color: #fff;
    text-decoration: none;
}

.cmv2-carte .cmv2-popup__link svg {
    width: 14px;
    height: 14px;
}

/* Fix Leaflet popup close button position */
.cmv2-carte .leaflet-popup-close-button {
    top: 8px !important;
    right: 8px !important;
    width: 24px !important;
    height: 24px !important;
    font-size: 18px !important;
    color: #fff !important;
    background: rgba(0, 0, 0, 0.5) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.cmv2-carte .leaflet-popup-close-button:hover {
    background: rgba(0, 0, 0, 0.7) !important;
}

/* Adjust popup when no photo */
.cmv2-carte .cmv2-popup--no-photo .leaflet-popup-close-button {
    color: #333 !important;
    background: rgba(0, 0, 0, 0.1) !important;
}

/* =========================================================================
   Responsive Adjustments
   ========================================================================= */

@media (max-width: 768px) {
    .cmv2-carte .cmv2-carte__container {
        min-height: 250px;
        border-radius: 6px;
    }

    .cmv2-carte .cmv2-popup {
        min-width: 200px;
        max-width: 260px;
    }

    .cmv2-carte .cmv2-popup__photo {
        height: 120px;
    }
}

@media (max-width: 576px) {
    .cmv2-carte {
        margin: 1rem 0;
    }

    .cmv2-carte .cmv2-carte__container {
        min-height: 200px;
        border-radius: 4px;
    }

    .cmv2-carte .cmv2-carte__legend {
        font-size: 0.8125rem;
        padding: 0.375rem 0.5rem;
    }

    .cmv2-carte .cmv2-popup {
        min-width: 180px;
        max-width: 240px;
    }

    .cmv2-carte .cmv2-popup__title {
        font-size: 0.9375rem;
    }

    .cmv2-carte .cmv2-popup__details {
        font-size: 0.75rem;
    }

    .cmv2-carte .cmv2-popup__link {
        font-size: 0.8125rem;
        padding: 0.375rem 0.75rem;
    }
}
