/* ============================================================
   LYL MAPA DE COBERTURA v2.0
   ============================================================ */

/* --- Layout principal --- */
.mapa-app {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--navbar-height, 72px));
}

.mapa-map-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.mapa-container {
    width: 100%;
    height: 100%;
    z-index: 1;
    background: var(--slate-950, #020617);
}

/* --- Barra de búsqueda --- */
.mapa-search-bar {
    background: var(--slate-900, #0f172a);
    border-bottom: 1px solid var(--slate-800, #1e293b);
    padding: 1rem 1.5rem;
    z-index: 10;
}

.mapa-search-form {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
}

.mapa-search-icon {
    position: absolute;
    left: 1rem;
    color: var(--slate-400, #94a3b8);
    pointer-events: none;
}

.mapa-search-input {
    width: 100%;
    padding: 0.75rem 5rem 0.75rem 3rem;
    background: var(--slate-800, #1e293b);
    border: 1px solid var(--slate-700, #334155);
    border-radius: 0.75rem;
    color: #fff;
    font-family: inherit;
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.mapa-search-input::placeholder {
    color: var(--slate-500, #64748b);
}

.mapa-search-input:focus {
    border-color: var(--blue-500, #3b82f6);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.mapa-search-btn {
    position: absolute;
    right: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--blue-600, #2563eb);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.3s;
}

.mapa-search-btn:hover {
    background: var(--blue-500, #3b82f6);
}

/* --- Leaflet control overrides --- */
.mapa-container .leaflet-control-zoom a {
    background: #fff !important;
    color: #333 !important;
    border-color: #ccc !important;
}

.mapa-container .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.85) !important;
    color: #666 !important;
    font-size: 10px !important;
}

.mapa-container .leaflet-control-attribution a {
    color: var(--blue-600, #2563eb) !important;
}

.mapa-container .leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.mapa-container .leaflet-popup-tip {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* --- Panel de filtros de operadores --- */
.mapa-filter-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    width: 14.5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 0.75rem;
    border: 1px solid rgba(229, 231, 235, 0.8);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    max-height: calc(100% - 2rem);
    overflow-y: auto;
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.filter-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.filter-actions {
    display: flex;
    gap: 0.25rem;
}

.filter-action-btn {
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
    background: #f3f4f6;
    color: #6b7280;
}

.filter-action-btn:hover {
    background: #e5e7eb;
}

.filter-action-btn.active {
    background: var(--blue-600, #2563eb);
    color: #fff;
}

/* Operator items */
.filter-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    margin-bottom: 0.25rem;
}

.filter-item:hover {
    background: #f9fafb;
}

.filter-item.selected {
    background: #f9fafb;
    border-color: #e5e7eb;
}

.filter-item.deselected {
    opacity: 0.5;
}

.filter-color-dot {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid;
    transition: background 0.2s;
}

.filter-item.deselected .filter-color-dot {
    background: transparent !important;
}

.filter-item-info {
    flex: 1;
    min-width: 0;
}

.filter-item-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-item-tech {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    color: #9ca3af;
}

.filter-tech-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    display: inline-block;
}

/* Toggle switch */
.filter-toggle {
    width: 2rem;
    height: 1.25rem;
    border-radius: 9999px;
    background: #d1d5db;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}

.filter-toggle.on {
    background: #22c55e;
}

.filter-toggle-knob {
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.filter-toggle.on .filter-toggle-knob {
    transform: translateX(0.75rem);
}

/* --- Botón de geolocalización --- */
.mapa-locate-wrapper {
    position: absolute;
    top: 6rem;
    right: 0.75rem;
    z-index: 1001;
}

.mapa-locate-btn {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.625rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #374151;
}

.mapa-locate-btn:hover {
    background: #f9fafb;
    transform: scale(1.05);
}

.mapa-locate-btn.loading {
    animation: pulse 1.5s infinite;
}

/* --- Alerta de ubicación --- */
.mapa-location-alert {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1002;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 28rem;
    color: #fff;
    font-size: 0.875rem;
}

.mapa-location-alert.success {
    background: #22c55e;
}

.mapa-location-alert.loading {
    background: #3b82f6;
}

.mapa-location-alert.denied {
    background: #ef4444;
}

.mapa-location-alert.error {
    background: #f59e0b;
}

.alert-icon {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    font-size: 0.8125rem;
    margin: 0;
}

.alert-subtitle {
    font-size: 0.6875rem;
    opacity: 0.9;
    margin: 0.125rem 0 0;
}

.alert-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.25rem;
    cursor: pointer;
    font-weight: 700;
    padding: 0;
    line-height: 1;
}

.alert-close:hover {
    color: #fff;
}

/* --- Panel informativo (desktop) --- */
.mapa-info-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 20rem;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--slate-700, #334155);
    z-index: 1000;
    display: none;
}

.mapa-info-panel h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
}

.mapa-steps {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mapa-steps li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--slate-300, #cbd5e1);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.mapa-steps li span {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.2);
    color: var(--blue-400, #60a5fa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
}

.mapa-cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--slate-700, #334155);
    background: linear-gradient(135deg, var(--blue-600, #2563eb), var(--cyan-600, #0891b2));
    color: #fff;
    border: none;
    border-radius: 0.75rem;
    text-decoration: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    transition: opacity 0.3s;
}

.mapa-cta-btn:hover {
    opacity: 0.9;
}

/* --- WhatsApp CTA --- */
.mapa-whatsapp-cta {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    max-width: 20rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 0.75rem;
    padding: 1rem;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border: 1px solid;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.mapa-whatsapp-cta.has-coverage {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    border-color: #4ade80;
}

.mapa-whatsapp-cta.no-coverage {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    border-color: #fbbf24;
}

.whatsapp-icon-wrap {
    flex-shrink: 0;
    color: #fff;
}

.whatsapp-icon-wrap svg {
    width: 1.5rem;
    height: 1.5rem;
}

.whatsapp-content {
    flex: 1;
}

.whatsapp-content h4 {
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}

.whatsapp-content p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.6875rem;
    margin: 0 0 0.75rem;
    line-height: 1.4;
}

.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.8125rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background: #fff;
    text-decoration: none;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.mapa-whatsapp-cta.has-coverage .whatsapp-btn {
    color: #16a34a;
}

.mapa-whatsapp-cta.no-coverage .whatsapp-btn {
    color: #d97706;
}

.whatsapp-btn:hover {
    transform: scale(1.05);
}

/* --- Loading overlay --- */
.mapa-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    text-align: center;
    color: var(--slate-400, #94a3b8);
    font-size: 0.875rem;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--blue-500, #3b82f6);
    border-top-color: transparent;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

/* --- Popup de cobertura --- */
.coverage-popup {
    text-align: center;
    padding: 0.5rem;
}

.coverage-popup .popup-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    margin: 0 auto 0.5rem;
}

.coverage-popup strong {
    font-size: 0.875rem;
    display: block;
}

.coverage-popup .popup-tech {
    font-size: 0.6875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.coverage-popup .popup-district {
    font-size: 0.8125rem;
    color: #4b5563;
    margin-top: 0.25rem;
}

/* --- Animaciones --- */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* --- Responsive --- */
@media (max-width: 767px) {
    .mapa-filter-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 1rem 1rem 0 0;
        max-height: 40vh;
        transform: translateY(calc(100% - 3rem));
        transition: transform 0.3s ease;
    }

    .mapa-filter-panel.expanded {
        transform: translateY(0);
    }

    .filter-header {
        cursor: pointer;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid #e5e7eb;
    }

    .filter-header::before {
        content: '';
        display: block;
        width: 2rem;
        height: 0.25rem;
        background: #d1d5db;
        border-radius: 9999px;
        margin: 0 auto 0.5rem;
    }

    .mapa-info-panel {
        display: none !important;
    }

    .mapa-whatsapp-cta {
        bottom: 3.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }
}

@media (min-width: 768px) {
    .mapa-filter-panel {
        max-height: calc(100% - 8rem);
    }
}

@media (min-width: 1024px) {
    .mapa-info-panel {
        display: block;
    }
}