/**
 * Proprietary License - All Rights Reserved
 *
 * Copyright (c) 2026 Hardware Online
 *
 * All rights reserved. This software and its source files are the
 * intellectual property of Hardware Online. Authored by gommergab.
 *
 * Unauthorized copying, modification, distribution or use of this
 * software, in whole or in part, is strictly prohibited without the
 * prior written permission of Hardware Online.
 *
 * This software is provided "as is", without warranty of any kind,
 * express or implied, including but not limited to the warranties of
 * merchantability, fitness for a particular purpose and non-infringement.
 *
 * @author gommergab
 * @copyright 2026 Hardware Online
 * @license Proprietary
 */

/**
 * ho_avancedsearch — skeleton / spinner / fade en resultados + layout de la barra del drawer.
 */

/* --------------------------------------------------------------------------
 * Drawer: input de búsqueda + botón cerrar (SVG) en una sola fila; la X queda
 * a la derecha, visualmente dentro del campo (posición absoluta sobre el input).
 * -------------------------------------------------------------------------- */
#ho_search_layer .ho_search_searchbar_container {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    min-width: 0;
}

#ho_search_layer .ho_search_searchbar_container .ho_searchbox {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    /* Hueco para que el texto no quede bajo el botón y la X se lea “dentro” del input */
    padding-right: 3rem;
}

#ho_search_layer .ho_search_searchbar_container .ho_search_closebutton {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* El tema (drawer-top) suele reservar padding-right en el header para un cierre global;
   aquí el cierre va dentro de la barra. */
#ho_search_layer #ho_search_header.ho_search_header {
    padding-right: 1.25rem;
}

/*
 * Input disparador (readonly): ocultar la “x” nativa de WebKit para type=search,
 * que en algunos layouts aparece mal colocada y no aporta al abrir solo el drawer.
 */
#ho_avancedsearch .ho_search_trigger_input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

#ho_search_results {
    transition: opacity 0.4s ease;
}

#ho_search_results.ho_search_loading {
    opacity: 0.7;
}

#ho_search_results.ho_search_results_loaded {
    opacity: 1;
    animation: hoFadeIn 0.4s ease;
}

@keyframes hoFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Skeleton */
.ho_search_skeleton_container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    padding: 5px;
}

.ho_search_skeleton_product {
    display: flex;
    flex-direction: column;
    animation: hoSkeletonPulse 1.5s ease-in-out infinite;
}

.ho_search_skeleton_image {
    width: 100%;
    margin-bottom: 12px;
    aspect-ratio: 1 / 1;
    background: linear-gradient(
        90deg,
        var(--tile) 0%,
        var(--line) 50%,
        var(--tile) 100%
    );
    background-size: 200% 100%;
    border-radius: var(--radius-lg);
    animation: hoSkeletonShimmer 1.5s ease-in-out infinite;
}

.ho_search_skeleton_content {
    padding: 0 4px;
}

.ho_search_skeleton_line {
    height: 16px;
    margin-bottom: 8px;
    background: linear-gradient(
        90deg,
        var(--tile) 0%,
        var(--line) 50%,
        var(--tile) 100%
    );
    background-size: 200% 100%;
    border-radius: 4px;
    animation: hoSkeletonShimmer 1.5s ease-in-out infinite;
}

.ho_search_skeleton_title {
    width: 85%;
    height: 18px;
}

.ho_search_skeleton_price {
    width: 60%;
    height: 20px;
    margin-top: 8px;
}

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

@keyframes hoSkeletonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Spinner (fallback cuando no hay skeleton) */
.ho_search_loading_spinner {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.ho_search_spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: hoSpinner 0.8s linear infinite;
}

.ho_search_loading_text {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--sub);
    animation: hoTextPulse 1.5s ease-in-out infinite;
}

@keyframes hoSpinner {
    to { transform: rotate(360deg); }
}

@keyframes hoTextPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --------------------------------------------------------------------------
 * Rango de precio (dos <input type="range">): misma pista que .range-slider__track
 * (Burrrry); sin esto los inputs van en bloque y parecen dos sliders apilados.
 * -------------------------------------------------------------------------- */
.ho_search_price_slider_container {
    --ho-rs-thumb: 22px;
    --ho-rs-track-h: 6px;
    position: relative;
    width: 100%;
    min-height: calc(var(--ho-rs-thumb) + 4px);
    margin-top: 2px;
}

.ho_search_price_slider_track {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: var(--ho-rs-track-h);
    margin-top: calc(var(--ho-rs-track-h) / -2);
    border-radius: var(--radius-full);
    background: var(--line);
    z-index: 1;
    pointer-events: none;
}

.ho_search_price_slider_container .ho_price_slider {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 0;
    margin: 0;
    padding: 0;
    transform: translateY(-50%);
    appearance: none;
    background: transparent;
    pointer-events: none;
    z-index: 3;
    outline: none;
}

.ho_search_price_slider_container .ho_price_slider::-webkit-slider-thumb {
    appearance: none;
    width: var(--ho-rs-thumb);
    height: var(--ho-rs-thumb);
    border-radius: 50%;
    background: var(--bg);
    border: 3px solid var(--brand);
    box-shadow: var(--shadow-sm);
    pointer-events: all;
    cursor: grab;
}

.ho_search_price_slider_container .ho_price_slider::-moz-range-thumb {
    width: var(--ho-rs-thumb);
    height: var(--ho-rs-thumb);
    border-radius: 50%;
    background: var(--bg);
    border: 3px solid var(--brand);
    box-shadow: var(--shadow-sm);
    pointer-events: all;
    cursor: grab;
}

.ho_search_price_slider_container .ho_price_slider::-webkit-slider-runnable-track {
    appearance: none;
    height: 0;
    background: transparent;
}

.ho_search_price_slider_container .ho_price_slider::-moz-range-track {
    height: 0;
    background: transparent;
    border: none;
}

.ho_search_price_slider_container #ho_price_max {
    z-index: 4;
}
