/* Oculta el texto "Leaflet" en la atribución del mapa, dejando sólo los créditos de OpenStreetMap. */
.leaflet-control-attribution a:first-child {
    display: none;
}

.leaflet-control-attribution span {
    display: none;
}

/* Leaflet tooltips for store labels */
.store-tooltip {
    font-size: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7ff 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 14px;
    padding: 8px 12px;
    color: #1f2937;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.2);
    opacity: 1 !important;
    max-width: 260px;
    backdrop-filter: blur(8px);
    position: relative;
}

.store-tooltip.leaflet-tooltip:before {
    display: none;
}

.store-tooltip::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7ff 100%);
    border-right: 1px solid rgba(99, 102, 241, 0.2);
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 6px 6px 14px rgba(15, 23, 42, 0.14);
}

/* Centrar el contenido del tooltip sobre el marcador */
.store-tooltip .leaflet-tooltip-content {
    text-align: center;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transform: scale(var(--storeTooltipScale, 1));
    transform-origin: bottom center;
    font-weight: 600;
    letter-spacing: 0.2px;
    padding: 2px 0;
}

/* Puntito de color en el cartel para identificar tienda */
.store-tooltip .tt-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.store-tooltip .tt-text {
    font-weight: 700;
    letter-spacing: 0.25px;
    overflow-wrap: anywhere;
    max-width: 220px;
    text-transform: capitalize;
    padding-left: 6px;
}

/* Icono de ubicación del usuario (diana) para el mapa */
.user-location-icon .user-pin {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #7dd3fc 40%, #2563eb 100%);
    border: 3px solid #0f172a;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2), 0 8px 18px rgba(15, 23, 42, 0.35);
    position: relative;
}

.user-location-icon .user-pin::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 4px;
    background: #0f172a;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.user-location-icon .user-pin::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 999px;
    border: 2px solid rgba(37, 99, 235, 0.25);
    box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.12);
    animation: userGlow 2.2s ease-in-out infinite;
}

/* Brújula renovada con estética limpia y buen contraste sobre mapa */
#map-modal .leaflet-control.compass-control {
    margin-right: 12px;
    margin-bottom: 18px;
    border: none;
    box-shadow: none;
    background: transparent;
    z-index: 1100;
}

#map-modal .compass-btn {
    --compass-heading: 0deg;
    width: 39px;
    height: 39px;
    border: 1px solid rgba(15, 23, 42, 0.22);
    border-radius: 50%;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 247, 255, 0.98) 100%);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    transition: transform 0.16s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

#map-modal .compass-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(79, 70, 229, 0.6);
    box-shadow: 0 14px 24px rgba(15, 23, 42, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.98);
}

#map-modal .compass-btn:active {
    transform: translateY(0);
}

#map-modal .compass-btn:focus-visible {
    outline: 3px solid rgba(99, 102, 241, 0.28);
    outline-offset: 2px;
}

#map-modal .compass-btn.is-loading {
    cursor: progress;
    opacity: 0.8;
}

#map-modal .compass-btn.active {
    border-color: rgba(79, 70, 229, 0.85);
    box-shadow: 0 14px 24px rgba(79, 70, 229, 0.28), 0 0 0 2px rgba(124, 58, 237, 0.16);
}

#map-modal .compass-face {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    position: relative;
    border: 1px solid rgba(79, 70, 229, 0.45);
    background: radial-gradient(circle at 35% 30%, #ffffff 0%, #eef2ff 68%, #dbe5ff 100%);
}

#map-modal .compass-arrow {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    transform: translate(-50%, -50%) rotate(var(--compass-heading));
    transform-origin: 50% 50%;
    transition: transform 0.12s linear;
}

#map-modal .compass-arrow::before,
#map-modal .compass-arrow::after {
    content: '';
    position: absolute;
    left: -4px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

#map-modal .compass-arrow::before {
    top: -10px;
    border-bottom: 10px solid #ef4444;
}

#map-modal .compass-arrow::after {
    top: 0;
    border-top: 10px solid #3b82f6;
}

#map-modal .compass-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #0f172a;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
}

body.onboarding-active.onboarding-map-step #map-modal .leaflet-control.compass-control {
    z-index: 7200;
}

@media (max-width: 600px) {
    #map-modal .leaflet-control.compass-control {
        margin-right: 10px;
        margin-bottom: 14px;
    }

    #map-modal .compass-btn {
        width: 37px;
        height: 37px;
    }

    #map-modal .compass-face {
        width: 22px;
        height: 22px;
    }

    #map-modal .compass-arrow::before {
        top: -9px;
        border-left-width: 3.5px;
        border-right-width: 3.5px;
        border-bottom-width: 9px;
    }

    #map-modal .compass-arrow::after {
        border-left-width: 3.5px;
        border-right-width: 3.5px;
        border-top-width: 9px;
    }
}

@keyframes userGlow {
    0% {
        box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
        opacity: 0.7;
    }

    50% {
        box-shadow: 0 0 0 10px rgba(37, 99, 235, 0.22);
        opacity: 1;
    }

    100% {
        box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
        opacity: 0.7;
    }
}

/* Marcador con label integrado (siempre visible) */
.custom-svg-marker-labeled {
    background: transparent !important;
    border: none !important;
    overflow: visible !important;
}

.marker-with-label {
    position: relative;
    display: block;
    pointer-events: auto;
}

.marker-with-label svg {
    display: block;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.marker-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 2px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 4px;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

/* MarkerCluster estilos personalizados */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 20px;
}

.marker-cluster div {
    width: 32px;
    height: 32px;
    margin-left: 4px;
    margin-top: 4px;
    text-align: center;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster-small {
    background: rgba(99, 102, 241, 0.5);
}

.marker-cluster-small div {
    background: #6366f1;
}

.marker-cluster-medium {
    background: rgba(245, 158, 11, 0.5);
}

.marker-cluster-medium div {
    background: #f59e0b;
}

.marker-cluster-large {
    background: rgba(239, 68, 68, 0.5);
}

.marker-cluster-large div {
    background: #ef4444;
}

/* Leaflet: evitar líneas blancas entre los tiles */
.leaflet-container {
    background: #e6e6e6;
}

.leaflet-container .leaflet-tile {
    border: 0 !important;
    outline: 1px solid transparent;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    image-rendering: -webkit-optimize-contrast;
}

.leaflet-pane {
    will-change: transform;
}

.leaflet-tile-container {
    will-change: transform;
}

/* ========== TIENDAS FÍSICAS - ESTILOS PROFESIONALES ========== */
.tienda.tienda-fisica {
    position: relative;
    background: transparent;
    border: none;
    box-shadow: none;
}

.tienda.tienda-fisica h3 {
    font-size: 1.3em;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    text-align: center;
}

.tienda.tienda-fisica h4 {
    font-size: 0.95em;
    color: #64748b;
    font-weight: 500;
    padding: 8px 14px;
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 10px;
    border-left: 3px solid #8b5cf6;
    margin: 12px 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tienda.tienda-fisica h4::before {
    content: '📍';
    font-size: 14px;
}

/* ===== Mayoristas: mismos estilos que tiendas físicas ===== */
.tienda.tienda-mayorista h3 {
    font-size: 1.3em;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    text-align: center;
}

.tienda.tienda-mayorista h4 {
    font-size: 0.95em;
    color: #64748b;
    font-weight: 500;
    padding: 8px 14px;
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 10px;
    border-left: 3px solid #8b5cf6;
    margin: 12px 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tienda.tienda-mayorista h4::before {
    content: '📍';
    font-size: 14px;
}

.tienda.tienda-mayorista .card {
    border: 1px solid rgba(139, 92, 246, 0.15);
    background: linear-gradient(180deg, #ffffff 0%, #faf8ff 100%);
}

.tienda.tienda-mayorista .card:hover {
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 12px 28px rgba(139, 92, 246, 0.18);
}

.tienda.tienda-mayorista .card:has(.checkbox-container input[type="checkbox"]:checked) {
    background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
    border-color: rgba(139, 92, 246, 0.5);
}

.tienda.tienda-fisica .card {
    border: 1px solid rgba(139, 92, 246, 0.15);
    background: linear-gradient(180deg, #ffffff 0%, #faf8ff 100%);
}

.tienda.tienda-fisica .card:hover {
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 12px 28px rgba(139, 92, 246, 0.18);
}

.tienda.tienda-fisica .card:has(.checkbox-container input[type="checkbox"]:checked) {
    background: linear-gradient(180deg, #f5f3ff 0%, #ede9fe 100%);
    border-color: rgba(139, 92, 246, 0.5);
}

@media (max-width: 600px) {
    /* Tiendas físicas: en móvil el checkbox debe ir arriba de la imagen */
    #tiendas-fisicas-results .producto-grid .card label {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: center;
        text-align: center;
        width: 100%;
    }

    #tiendas-fisicas-results .producto-grid .card .checkbox-container {
        order: 0;
        align-self: center;
    }

    #tiendas-fisicas-results .producto-grid .card .product-chip {
        order: 1;
        align-self: center;
    }

    #tiendas-fisicas-results .producto-grid .card .img-container {
        order: 2;
        width: auto;
    }

    #tiendas-fisicas-results .producto-grid .card .product-name {
        order: 3;
        width: 100%;
    }

    #tiendas-fisicas-results .producto-grid .card .precio {
        order: 4;
        width: 100%;
    }
}

@media (max-width: 600px) {
    /* Ajustes móviles para el modal del mapa */
    #map-modal {
        align-items: center;
        justify-content: center;
        padding: 0;
        overflow: hidden;
    }

    #map-modal .modal-content {
        max-height: 90dvh;
        width: 94dvw;
        margin: auto;
        padding: 10px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    body.onboarding-active #map-modal .modal-content {
        max-height: calc(100dvh - 80px - var(--onboarding-reserve-h, 90px));
    }

    /* Forzar altura del mapa en móviles, sobreescribiendo el inline style (420px) */
    #leaflet-map {
        height: min(42dvh, 280px) !important;
        min-height: 180px;
    }

    body.onboarding-active.onboarding-map-step #leaflet-map {
        height: min(28dvh, 200px) !important;
        min-height: 140px;
    }
}
