/**
 * panel-buscador.css
 * Estilos para el Panel Dedicado de Búsqueda de Productos (IORO)
 * Optimizado para móvil (pantalla completa nativa) y escritorio (modal spotlight).
 */

/* ============================================================== */
/* 1. ESTRUCTURA Y OVERLAY GLOBAL                                 */
/* ============================================================== */
.panel-buscador-modal {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
}

.panel-buscador-modal.activo {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Bloqueo de scroll en body al abrir el panel */
body.panel-buscador-abierto {
    overflow: hidden !important;
}

.panel-buscador-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 7, 15, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: opacity 0.25s ease;
}

.panel-buscador-contenedor {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #0b101e;
    transform: translateY(16px);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel-buscador-modal.activo .panel-buscador-contenedor {
    transform: translateY(0);
}

/* ============================================================== */
/* 2. CABECERA DEL BUSCADOR                                       */
/* ============================================================== */
.panel-buscador-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: max(12px, env(safe-area-inset-top, 12px)) 16px 12px 16px;
    background: rgba(14, 21, 38, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    z-index: 5;
    flex-shrink: 0;
}

/* Botón Volver (Móvil) */
.btn-panel-buscador-volver {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.18s, transform 0.18s, color 0.18s;
}

.btn-panel-buscador-volver:hover,
.btn-panel-buscador-volver:active {
    background: rgba(212, 175, 55, 0.2);
    border-color: rgba(212, 175, 55, 0.4);
    color: #d4af37;
    transform: scale(0.95);
}

/* Caja de Input */
.panel-buscador-input-box {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(212, 175, 55, 0.35);
    border-radius: 24px;
    padding: 0 14px;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.panel-buscador-input-box:focus-within {
    border-color: #d4af37;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.panel-buscador-icono-lupa {
    color: #d4af37;
    font-size: 15px;
    flex-shrink: 0;
}

.panel-buscador-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 15px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

.panel-buscador-input::placeholder {
    color: #64748b;
    font-weight: 400;
}

/* Quitar botón por defecto de webkit search */
.panel-buscador-input::-webkit-search-decoration,
.panel-buscador-input::-webkit-search-cancel-button,
.panel-buscador-input::-webkit-search-results-button,
.panel-buscador-input::-webkit-search-results-decoration {
    display: none;
}

/* Botón Limpiar texto */
.btn-panel-buscador-limpiar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: color 0.18s, transform 0.18s;
}

.btn-panel-buscador-limpiar:hover,
.btn-panel-buscador-limpiar:active {
    color: #ef4444;
    transform: scale(1.1);
}

/* Botón Cerrar Desktop (Oculto en móvil) */
.btn-panel-buscador-cerrar-desktop {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-panel-buscador-cerrar-desktop:hover {
    color: #ffffff;
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

/* ============================================================== */
/* 3. CHIPS DE SUGERENCIAS / TENDENCIAS                           */
/* ============================================================== */
.panel-buscador-chips-seccion {
    padding: 10px 16px 8px 16px;
    background: rgba(14, 21, 38, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.panel-buscador-chips-header {
    font-size: 11.5px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.panel-buscador-chips-lista {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
}

.panel-buscador-chips-lista::-webkit-scrollbar {
    display: none;
}

.panel-buscador-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    color: #cbd5e1;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
}

.panel-buscador-chip i {
    font-size: 11px;
    color: #d4af37;
}

.panel-buscador-chip:hover,
.panel-buscador-chip:active {
    background: rgba(212, 175, 55, 0.18);
    border-color: rgba(212, 175, 55, 0.5);
    color: #ffffff;
    transform: translateY(-1px);
}

/* ============================================================== */
/* 4. ÁREA DE SCROLL Y ESTADOS                                    */
/* ============================================================== */
.panel-buscador-scroll-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 14px 16px max(24px, env(safe-area-inset-bottom, 24px)) 16px;
}

/* 4.1 Estado Inicial */
.panel-buscador-estado-inicial {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    max-width: 380px;
    margin: 0 auto;
}

.panel-buscador-icono-vacio {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #d4af37;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin-bottom: 16px;
}

.panel-buscador-titulo-vacio {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
    font-family: 'Space Grotesk', sans-serif;
}

.panel-buscador-desc-vacio {
    font-size: 13px;
    color: #8da2bb;
    line-height: 1.5;
    margin: 0;
}

/* 4.2 Meta Resultados (Contador y Filtro) */
.panel-buscador-meta-resultados {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding: 0 4px;
}

#panelBuscadorTotalTexto {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Botón Filtro Rápido de Disponibilidad */
.btn-filtro-solo-stock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    user-select: none;
    flex-shrink: 0;
}

.btn-filtro-solo-stock:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    border-color: rgba(212, 175, 55, 0.4);
}

.btn-filtro-solo-stock.activo {
    background: rgba(16, 185, 129, 0.16);
    border-color: #10b981;
    color: #34d399;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.22);
}

.btn-filtro-solo-stock.activo i {
    color: #10b981;
}

/* 4.3 Lista de Resultados */
.panel-buscador-lista {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Tarjeta Compacta de Producto */
.panel-buscador-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.panel-buscador-item:hover,
.panel-buscador-item:active {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.4);
    transform: translateY(-1px);
}

/* Variante Agotada de la Tarjeta */
.panel-buscador-item.panel-buscador-item-agotado {
    opacity: 0.72;
    background: rgba(239, 68, 68, 0.03);
    border-color: rgba(239, 68, 68, 0.18);
}

.panel-buscador-item.panel-buscador-item-agotado .panel-buscador-thumb {
    filter: grayscale(45%);
}

.panel-buscador-item.panel-buscador-item-agotado:hover,
.panel-buscador-item.panel-buscador-item-agotado:active {
    opacity: 0.96;
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.4);
}

.panel-buscador-item.panel-buscador-item-agotado:hover .panel-buscador-thumb {
    filter: grayscale(0%);
}

.panel-buscador-thumb-wrap {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 10px;
    overflow: hidden;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-buscador-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.2s ease;
}

/* Etiqueta flotante "Agotado" sobre la miniatura */
.panel-buscador-thumb-overlay-agotado {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(220, 38, 38, 0.92);
    color: #ffffff;
    font-size: 8.5px;
    font-weight: 800;
    text-transform: uppercase;
    text-align: center;
    padding: 2px 0;
    letter-spacing: 0.5px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.4);
}

.panel-buscador-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.panel-buscador-nombre {
    font-size: 13.5px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-buscador-badges-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.panel-buscador-badge-oficial {
    font-size: 10px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(212, 175, 55, 0.14);
    color: #d4af37;
    border: 1px solid rgba(212, 175, 55, 0.35);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.panel-buscador-badge-tienda {
    font-size: 10px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.panel-buscador-badge-cat {
    font-size: 10px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    white-space: nowrap;
}

/* Badges de Existencia / Stock */
.panel-buscador-badge-agotado {
    font-size: 10px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
    font-weight: 700;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3.5px;
}

.panel-buscador-badge-disponible {
    font-size: 10px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(16, 185, 129, 0.14);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3.5px;
}

.panel-buscador-badge-pocas-unidades {
    font-size: 10px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(245, 158, 11, 0.16);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.38);
    font-weight: 700;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3.5px;
    animation: pulsoPocasUnidades 2.2s infinite ease-in-out;
}

@keyframes pulsoPocasUnidades {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.72; }
}

.panel-buscador-badge-servicio {
    font-size: 10px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(59, 130, 246, 0.14);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3.5px;
}

.panel-buscador-precio {
    font-size: 14.5px;
    font-weight: 700;
    color: #d4af37;
    font-family: 'Space Grotesk', sans-serif;
    margin-top: 1px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.panel-buscador-precio.precio-agotado {
    color: #94a3b8;
}

.panel-buscador-label-sin-stock {
    font-size: 11px;
    font-weight: 600;
    color: #ef4444;
    font-family: 'Montserrat', sans-serif;
}

.panel-buscador-flecha {
    color: #64748b;
    font-size: 12px;
    margin-left: auto;
    padding-left: 6px;
    flex-shrink: 0;
    transition: color 0.18s, transform 0.18s;
}

.panel-buscador-item:hover .panel-buscador-flecha,
.panel-buscador-item:active .panel-buscador-flecha {
    color: #d4af37;
    transform: translateX(3px);
}

/* Resaltado del texto coincidente */
mark.resaltado-busqueda {
    background: rgba(212, 175, 55, 0.28);
    color: #ffd700;
    font-weight: 700;
    padding: 0 1px;
    border-radius: 2px;
}

/* 4.4 Estado Sin Resultados */
.panel-buscador-sin-resultados {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    max-width: 380px;
    margin: 0 auto;
}

.panel-buscador-sin-res-icono {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}

.panel-buscador-sin-res-titulo {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 6px;
}

.panel-buscador-sin-res-desc {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 14px;
    line-height: 1.4;
}

.panel-buscador-sugerencia-sin-res {
    font-size: 12px;
    color: #64748b;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    padding: 10px 14px;
    border-radius: 10px;
    line-height: 1.4;
}

/* ============================================================== */
/* 5. ANIMACIÓN DE DESTACADO EN LA TARJETA PRINCIPAL              */
/* ============================================================== */
@keyframes pulsoDestacadoIORO {
    0% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.85);
        outline: 2px solid rgba(212, 175, 55, 0.9);
        outline-offset: 2px;
        transform: scale(1);
    }
    45% {
        box-shadow: 0 0 35px 8px rgba(212, 175, 55, 0.75);
        outline: 3px solid #d4af37;
        outline-offset: 5px;
        transform: scale(1.025);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
        outline: 2px solid transparent;
        outline-offset: 2px;
        transform: scale(1);
    }
}

.producto-destacado-busqueda {
    animation: pulsoDestacadoIORO 1.9s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 40 !important;
    position: relative !important;
}

/* ============================================================== */
/* 6. RESPONSIVIDAD PARA ESCRITORIO (MODAL SPOTLIGHT)            */
/* ============================================================== */
@media (min-width: 769px) {
    .panel-buscador-modal {
        align-items: center;
        justify-content: flex-start;
        padding-top: 60px;
    }

    .panel-buscador-contenedor {
        width: 90%;
        max-width: 660px;
        height: auto;
        max-height: 78vh;
        border-radius: 20px;
        border: 1px solid rgba(212, 175, 55, 0.35);
        box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.85), 0 0 35px rgba(212, 175, 55, 0.15);
        overflow: hidden;
    }

    .panel-buscador-header {
        padding: 14px 18px;
    }

    /* En escritorio no se usa la flecha volver, sino la X de cerrar */
    .btn-panel-buscador-volver {
        display: none;
    }

    .btn-panel-buscador-cerrar-desktop {
        display: flex;
    }

    .panel-buscador-chips-seccion {
        padding: 10px 18px;
    }

    .panel-buscador-scroll-area {
        padding: 16px 18px 24px 18px;
    }
}
