/* ===============================================
   CSS BUSCADOR - EFECTO LIQUID GLASS
   =============================================== */

/* Contenedor principal del buscador */
.search-container {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 0.5rem;
}

/* Wrapper del input */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

/* Input de búsqueda con efecto LIQUID GLASS */
.search-input {
    width: 100%;
    padding: 0.6rem 2.8rem 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    
    /* EFECTO LIQUID GLASS */
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    
    color: #ffffff;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* Icono de búsqueda */
.search-icon {
    position: absolute;
    right: 1rem;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    z-index: 2;
}

.search-icon:hover {
    color: #ffffff;
    transform: scale(1.1);
}

/* Botón limpiar búsqueda */
.clear-search {
    position: absolute;
    right: 2.5rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: none;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    z-index: 2;
}

.clear-search.active {
    display: block;
}

.clear-search:hover {
    color: #ffffff;
    transform: scale(1.1);
}

/* Contenedor de resultados con LIQUID GLASS */
.search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    
    /* EFECTO LIQUID GLASS */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    
    border-radius: 15px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 1001;
}

.search-results.active {
    display: block;
    animation: slideDownGlass 0.3s ease;
}

@keyframes slideDownGlass {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll personalizado para resultados */
.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.search-results::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Item individual de resultado con efecto glass */
.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.search-result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.search-result-item:hover::before {
    opacity: 1;
}

.search-result-item:hover {
    background: rgba(229, 37, 33, 0.05);
    transform: translateX(5px);
}

.search-result-item:last-child {
    border-bottom: none;
}

/* Imagen del resultado */
.result-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Información del producto */
.result-info {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-category {
    font-size: 0.8rem;
    color: #666;
}

/* Mensaje sin resultados */
.no-results {
    padding: 2rem;
    text-align: center;
    color: #666;
}

.no-results i {
    font-size: 3rem;
    color: rgba(0, 0, 0, 0.2);
    margin-bottom: 1rem;
    display: block;
}

/* ===============================================
   RESPONSIVE BREAKPOINTS
   =============================================== */

/* Desktop grande (1200px+) */
@media (min-width: 1200px) {
    .search-container {
        max-width: 350px;
    }
}

/* Laptop / Tablet horizontal (1024px - 1199px) */
@media (max-width: 1199px) {
    .search-container {
        max-width: 280px;
    }
}

/* Tablet (768px - 1023px) */
@media (max-width: 1023px) {
    .search-container {
        max-width: 240px;
        margin: 0 0.3rem;
    }

    .search-input {
        font-size: 0.85rem;
        padding: 0.55rem 2.6rem 0.55rem 0.9rem;
    }

    .search-icon {
        right: 0.85rem;
        font-size: 0.85rem;
    }

    .clear-search {
        right: 2.3rem;
        font-size: 0.8rem;
    }

    .search-results {
        max-height: 350px;
    }

    .result-image {
        width: 45px;
        height: 45px;
    }

    .result-title {
        font-size: 0.9rem;
    }

    .result-category {
        font-size: 0.75rem;
    }
}

/* ===============================================
   MÓVIL: SOLO ICONO DE LUPA (767px y menor)
   =============================================== */

@media (max-width: 767px) {
    .search-container {
        max-width: auto;
        width: auto;
        margin: 0;
    }

    /* Ocultar el input en móvil */
    .search-input {
        display: none;
    }

    /* Convertir el icono en un botón independiente con efecto glass */
    .search-icon {
        position: static;
        font-size: 1.2rem;
        color: #ffffff;
        padding: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        transition: all 0.3s ease;
    }

    .search-icon:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(1.1);
    }

    /* Ocultar botón de limpiar en móvil */
    .clear-search {
        display: none !important;
    }

    /* Ajustar resultados para móvil */
    .search-results {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        max-height: calc(100vh - 80px);
        border-radius: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    .search-result-item {
        padding: 0.8rem;
        gap: 0.8rem;
    }

    .result-image {
        width: 40px;
        height: 40px;
    }

    .result-title {
        font-size: 0.85rem;
    }

    .result-category {
        font-size: 0.7rem;
    }

    .no-results {
        padding: 1.5rem;
    }

    .no-results i {
        font-size: 2.5rem;
    }
}

/* Móvil mediano (376px - 480px) */
@media (max-width: 480px) {
    .search-icon {
        font-size: 1.1rem;
        width: 38px;
        height: 38px;
    }

    .search-results {
        top: 55px;
    }

    .search-result-item {
        padding: 0.7rem;
        gap: 0.7rem;
    }

    .result-image {
        width: 35px;
        height: 35px;
    }

    .result-title {
        font-size: 0.8rem;
    }

    .result-category {
        font-size: 0.65rem;
    }

    .no-results {
        padding: 1.2rem;
    }

    .no-results i {
        font-size: 2rem;
    }
}

/* Móvil pequeño (menos de 376px) */
@media (max-width: 375px) {
    .search-icon {
        font-size: 1rem;
        width: 36px;
        height: 36px;
        padding: 0.4rem;
    }

    .search-results {
        top: 50px;
        max-height: calc(100vh - 70px);
    }

    .search-result-item {
        padding: 0.6rem;
        gap: 0.6rem;
    }

    .result-image {
        width: 32px;
        height: 32px;
        border-radius: 4px;
    }

    .result-title {
        font-size: 0.75rem;
    }

    .result-category {
        font-size: 0.6rem;
    }

    .no-results {
        padding: 1rem;
    }

    .no-results i {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
    }

    .no-results p {
        font-size: 0.8rem;
    }
}

/* ===============================================
   AJUSTES PARA LANDSCAPE EN MÓVILES
   =============================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .search-results {
        max-height: 60vh;
    }

    .search-result-item {
        padding: 0.5rem;
    }

    .result-image {
        width: 35px;
        height: 35px;
    }

    .no-results {
        padding: 1rem;
    }

    .no-results i {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
}

/* ===============================================
   MODO EXPANDIDO EN MÓVIL CON LIQUID GLASS
   =============================================== */
@media (max-width: 767px) {
    /* Cuando el buscador se expande en móvil */
    .search-container.expanded {
        position: fixed;
        top: 15px;
        left: 61px;
        right: 105px;
        width: auto;
        max-width: none;
        z-index: 1002;
        animation: expandGlass 0.3s ease;
    }

    @keyframes expandGlass {
        from {
            opacity: 0;
            transform: scale(0.95);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }

    .search-container.expanded .search-input {
        display: block;
    }

    .search-container.expanded .search-icon {
        position: absolute;
        right: 1rem;
        font-size: 0.9rem;
        color: rgba(255, 255, 255, 0.9);
        width: auto;
        height: auto;
        padding: 0;
        background: transparent;
        backdrop-filter: none;
    }

    .search-container.expanded .clear-search.active {
        display: block !important;
        position: absolute;
        right: 2.5rem;
    }
}

/* Overlay con efecto glass */
.search-overlay {
    display: none;
}

@media (max-width: 767px) {
    .search-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        z-index: 999;
        animation: fadeIn 0.3s ease;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===============================================
   MEJORAS DE ACCESIBILIDAD
   =============================================== */

@media (prefers-reduced-motion: reduce) {
    .search-input,
    .search-icon,
    .clear-search,
    .search-result-item,
    .search-results,
    .search-container.expanded {
        animation: none !important;
        transition: none !important;
    }
}

@media (prefers-contrast: high) {
    .search-input {
        border-width: 2px;
        background: rgba(255, 255, 255, 0.2);
    }

    .search-result-item {
        border-bottom-width: 2px;
    }

    .result-title {
        font-weight: 700;
    }
    
    @media (max-width: 767px) {
        .search-icon {
            border: 2px solid rgba(255, 255, 255, 0.5);
        }
    }
}