/**
 * PDC Map - Styles carte minimaliste
 *
 * @package PDC
 * @since 1.0.0
 */

/* ========================================
   Container de la carte
   ======================================== */

.pdc-map {
    width: 100%;
    height: 250px;
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
    background-color: var(--map-bg);
    position: relative;
    z-index: 1; /* Contient les z-index élevés de Leaflet pour ne pas passer par-dessus le header sticky */
}

.pdc-map-lg {
    height: 350px;
}

.pdc-map-sm {
    height: 180px;
}

/* ========================================
   Leaflet Overrides
   ======================================== */

.pdc-map .leaflet-container {
    background: transparent;
    font-family: var(--font-family-base);
}

/* Masquer les contrôles par défaut */
.pdc-map .leaflet-control-container {
    display: none;
}

/* Afficher les contrôles de zoom sur la carte homepage */
.pdc-map-origins .leaflet-control-container {
    display: block;
}

.pdc-map-origins .leaflet-control-zoom {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.pdc-map-origins .leaflet-control-zoom a {
    background: var(--color-bg);
    color: var(--color-text);
    width: 30px;
    height: 30px;
    line-height: 30px;
    font-size: 16px;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.15s;
}

.pdc-map-origins .leaflet-control-zoom a:hover {
    background: var(--color-bg-secondary);
}

.pdc-map-origins .leaflet-control-zoom a:last-child {
    border-bottom: none;
}

/* ========================================
   Tooltip personnalisé
   ======================================== */

.pdc-map-tooltip {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 6px);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
}

.pdc-map-tooltip::before {
    display: none;
}

/* Tooltip riche avec aperçu image */
.pdc-map-tooltip--rich {
    padding: 0;
    min-width: 160px;
    overflow: hidden;
}

.pdc-map-tooltip-content {
    display: flex;
    flex-direction: column;
}

.pdc-map-tooltip-img {
    width: 160px;
    height: 100px;
    object-fit: cover;
    display: block;
    background: var(--color-bg-secondary);
}

.pdc-map-tooltip-city {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

/* ========================================
   Marqueur personnalisé
   ======================================== */

.pdc-map-marker-container {
    background: transparent;
    border: none;
}

.pdc-map-marker {
    position: relative;
    width: 24px;
    height: 24px;
}

.pdc-map-marker-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--map-highlight);
    border: 2px solid var(--color-bg);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.pdc-map-marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: var(--map-highlight);
    border-radius: 50%;
    opacity: 0.4;
    animation: pdc-map-pulse 2s ease-out infinite;
    z-index: 1;
}

@keyframes pdc-map-pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* ========================================
   Widget carte origine produit
   ======================================== */

.pdc-product-origin {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--color-border);
}

.pdc-product-origin-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pdc-product-origin-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--map-highlight);
    color: white;
    border-radius: 50%;
    flex-shrink: 0;
}

.pdc-product-origin-icon svg {
    width: 20px;
    height: 20px;
}

.pdc-product-origin-info {
    flex: 1;
    min-width: 0;
}

.pdc-product-origin-label {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.125rem;
}

.pdc-product-origin-country {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
}

.pdc-product-origin-region {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.pdc-product-origin-map {
    height: 200px;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

/* Version compacte (inline) */
.pdc-product-origin--compact {
    flex-direction: row;
    align-items: center;
    padding: 1rem;
}

.pdc-product-origin--compact .pdc-product-origin-map {
    width: 120px;
    height: 80px;
    flex-shrink: 0;
    order: -1;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .pdc-map {
        height: 200px;
    }

    .pdc-map-lg {
        height: 280px;
    }

    .pdc-product-origin {
        padding: 1rem;
    }

    .pdc-product-origin-map {
        height: 160px;
    }
}

/* ========================================
   Animation d'entrée
   ======================================== */

.pdc-map[data-animate] {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.pdc-map[data-animate].is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   États de chargement
   ======================================== */

.pdc-map-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--map-bg);
    z-index: 10;
}

.pdc-map-loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--map-border);
    border-top-color: var(--map-highlight);
    border-radius: 50%;
    animation: pdc-map-spin 0.8s linear infinite;
}

@keyframes pdc-map-spin {
    to {
        transform: rotate(360deg);
    }
}
