/* ===============================================
   BUSCADOR v2.1 - Búsquedas Recientes y Autocomplete Mejorado
   Estilo Minikidz - Sin emojis
   =============================================== */

/* Sección inicial (búsquedas recientes + productos populares) */
.buscador-seccion-inicial {
    padding: 24px;
    border-bottom: 1px solid #eee;
}

.buscador-seccion-inicial:last-child {
    border-bottom: none;
}

.buscador-seccion-inicial h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
    font-family: 'Ubuntu', sans-serif;
}

.seccion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.seccion-header h3 {
    margin: 0;
}

.btn-limpiar-recientes {
    background: none;
    border: none;
    color: #00A5F1;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    font-family: 'Open Sans', sans-serif;
}

.btn-limpiar-recientes:hover {
    background: #f0f0f0;
}

/* Lista de búsquedas recientes */
.busquedas-recientes-lista {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.busqueda-reciente-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
    font-family: 'Open Sans', sans-serif;
}

.busqueda-reciente-item:hover {
    background: #f8f9fa;
    border-color: #00A5F1;
    box-shadow: 0 2px 8px rgba(0, 165, 241, 0.1);
}

.busqueda-reciente-item i {
    font-size: 16px;
    color: #999;
}

.busqueda-reciente-item .texto {
    font-size: 15px;
    color: #333;
    font-weight: 500;
}

/* Sugerencias mejoradas */
.sugerencias-grupo {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.sugerencias-grupo:first-child {
    padding-top: 8px;
}

.sugerencias-grupo:last-child {
    border-bottom: none;
}

.sugerencias-titulo {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 16px;
    font-family: 'Ubuntu', sans-serif;
}

.sugerencias-lista {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sugerencia-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.sugerencia-item:hover {
    background: #f8f9fa;
}

.sugerencia-item .texto {
    font-size: 14px;
    color: #333;
    flex: 1;
    font-family: 'Open Sans', sans-serif;
}

.sugerencia-item .count {
    font-size: 12px;
    color: #999;
    font-weight: normal;
}

/* Indicadores visuales por tipo (sin emojis) */
.sugerencia-popular {
    font-weight: 500;
}

.sugerencia-popular::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #FF6060;
    border-radius: 0 2px 2px 0;
}

.sugerencia-marca {
    font-weight: 500;
}

.sugerencia-marca .texto {
    color: #00A5F1;
}

.sugerencia-categoria .texto {
    color: #666;
}

/* Texto vacío */
.texto-vacio {
    text-align: center;
    color: #999;
    padding: 20px;
    font-size: 14px;
    font-family: 'Open Sans', sans-serif;
}

/* ===============================================
   ANIMACIONES v2.0 - Mobile-First
   =============================================== */

/* 1. Fade In de Resultados (escalonado) */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.buscador-producto-card {
    animation: fadeInUp 0.4s ease-out;
    animation-fill-mode: both;
}

/* Efecto escalonado (primeros 12 productos) */
.buscador-producto-card:nth-child(1) { animation-delay: 0.05s; }
.buscador-producto-card:nth-child(2) { animation-delay: 0.08s; }
.buscador-producto-card:nth-child(3) { animation-delay: 0.11s; }
.buscador-producto-card:nth-child(4) { animation-delay: 0.14s; }
.buscador-producto-card:nth-child(5) { animation-delay: 0.17s; }
.buscador-producto-card:nth-child(6) { animation-delay: 0.20s; }
.buscador-producto-card:nth-child(7) { animation-delay: 0.23s; }
.buscador-producto-card:nth-child(8) { animation-delay: 0.26s; }
.buscador-producto-card:nth-child(9) { animation-delay: 0.29s; }
.buscador-producto-card:nth-child(10) { animation-delay: 0.32s; }
.buscador-producto-card:nth-child(11) { animation-delay: 0.35s; }
.buscador-producto-card:nth-child(12) { animation-delay: 0.38s; }

/* 2. Skeleton Loader */
.skeleton-loader {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e8e8e8 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
}

.skeleton-image {
    width: 100%;
    padding-top: 100%;
    background: #f0f0f0;
}

.skeleton-content {
    padding: 12px;
}

.skeleton-title {
    height: 16px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton-price {
    height: 14px;
    width: 40%;
}

/* 3. Destacar términos de búsqueda */
mark {
    background: #FFF3CD;
    color: #333;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* 4. Badge Popular */
.badge-popular {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #FF6060;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(255, 96, 96, 0.4);
    font-family: 'Ubuntu', sans-serif;
}

/* 5. Hover mejorado (touch-friendly) */
.buscador-producto-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Solo hover en desktop */
@media (hover: hover) and (pointer: fine) {
    .buscador-producto-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    }
    
    .buscador-producto-card:hover .producto-imagen {
        transform: scale(1.05);
    }
}

/* Touch feedback en mobile */
.buscador-producto-card:active {
    transform: scale(0.98);
    transition: transform 0.1s;
}

.producto-imagen {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 6. Animación abrir/cerrar buscador */
#resultados-buscador {
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#resultados-buscador.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

#resultados-buscador:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* 7. Botón "Ver más" animado */
.btn-ver-mas {
    position: relative;
    transition: all 0.3s ease;
}

.btn-ver-mas:active {
    transform: scale(0.96);
}

.btn-ver-mas.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-ver-mas.loading::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* 8. Indicador de carga general */
.buscador-loading {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.buscador-loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top-color: #00A5F1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

/* Optimizaciones de performance mobile */
.buscador-producto-card,
.producto-imagen,
#resultados-buscador {
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Responsive */
@media only screen and (max-width: 768px) {
    .buscador-seccion-inicial {
        padding: 16px;
    }
    
    .busqueda-reciente-item {
        padding: 10px 12px;
    }
    
    .busqueda-reciente-item .texto {
        font-size: 14px;
    }
    
    .sugerencias-titulo {
        font-size: 11px;
    }
    
    .sugerencia-item {
        padding: 8px 12px;
    }
    
    .sugerencia-item .texto {
        font-size: 13px;
    }
    
    /* Animaciones más rápidas en mobile */
    .buscador-producto-card {
        animation-duration: 0.3s;
    }
    
    .buscador-producto-card:nth-child(n+7) {
        animation-delay: 0.2s;
    }
    
    /* Badge más pequeño en mobile */
    .badge-popular {
        font-size: 9px;
        padding: 3px 6px;
        top: 6px;
        right: 6px;
    }
    
    /* Mark más sutil en mobile */
    mark {
        padding: 1px 3px;
    }
}
