/* ==========================================================================
   CABECERA E-COMMERCE (hybinetinterface)
   Ubicación: assets/css/header-shop.css
========================================================================== */

/* 1. Contenedor General */
.hybinet-header {
    background-color: var(--hybinet-palette-white);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Clase que el JS aplica al hacer scroll hacia abajo */
.hybinet-header.is-hidden {
    transform: translateY(calc(-1 * var(--header-main-height, 80px)));
}


/* 2. Barra Principal (Logo, Buscador, Iconos) */
.hybinet-header__main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 1.5rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

/* --- LOGO: estilos en header-shared.css (componente compartido con checkout) --- */

/* --- BUSCADOR --- */
.hybinet-header__search {
    flex-grow: 1;
    max-width: 700px;
    margin: 0 auto;
}

.hybinet-header__search form {
    display: flex;
    width: 100%;
    position: relative;
    align-items: center;
}

.hybinet-header__search input[type="search"] {
    width: 100%;
    padding: 8px 60px 8px 20px;
    border: 2px solid var(--hybinet-palette-black);
    border-radius: 50px;
    font-size: 0.95rem;
    color: var(--hybinet-color-text-primary);
    background-color: var(--hybinet-palette-white);
}

.hybinet-header__search input[type="search"]:focus {
    outline: none;
}

/* Ocultar la 'X' nativa que los navegadores (Chrome/Safari) inyectan en inputs type="search" */
.hybinet-header__search input[type="search"]::-webkit-search-decoration,
.hybinet-header__search input[type="search"]::-webkit-search-cancel-button,
.hybinet-header__search input[type="search"]::-webkit-search-results-button,
.hybinet-header__search input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

.hybinet-header__search button {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--hybinet-palette-black);
    color: var(--hybinet-palette-white);
    border: none;
    width: 48px; /* Ancho fijo para modo solo icono */
    height: calc(100% - 8px);
    border-radius: 40px; 
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.hybinet-header__search button:hover {
    background-color: var(--hybinet-palette-gray-dark);
}

.hybinet-header__search button svg {
    /* SVG size handled directly in HTML now, but keep margin reset if needed */
    flex-shrink: 0;
}

/* --- RESULTADOS BUSCADOR AJAX --- */
.hybinet-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--hybinet-palette-white);
    border: 1px solid var(--hybinet-color-border-subtle);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    font-size: 0.95rem;
}

.hybinet-search-results::-webkit-scrollbar {
    width: 6px;
}
.hybinet-search-results::-webkit-scrollbar-thumb {
    background: var(--hybinet-palette-gray);
    border-radius: 3px;
}

.hybinet-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--hybinet-color-text-primary);
    transition: background-color 0.2s;
}

.hybinet-search-item:hover,
.hybinet-search-item:focus {
    background-color: var(--hybinet-color-bg-subtle);
    outline: none;
}

.hybinet-search-item__img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
    background: var(--hybinet-color-bg-subtle);
    flex-shrink: 0;
}

.hybinet-search-item__info {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hybinet-search-item__title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.hybinet-search-item__price {
    font-weight: 700;
    color: var(--hybinet-color-text-primary);
}
.hybinet-search-item__price del {
    color: var(--hybinet-color-text-meta);
    font-weight: 400;
    font-size: 0.85em;
    margin-right: 4px;
}

.hybinet-search-empty,
.hybinet-search-loading {
    padding: 16px;
    text-align: center;
    color: var(--hybinet-color-text-meta);
}

.hybinet-search-loading .hybinet-svg-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    color: var(--hybinet-color-brand-accent-temporary, var(--hybinet-color-brand-accent));
    animation: hybinet-spin 1s linear infinite;
}

/* --- ACCIONES (Iconos) --- */
.hybinet-header__actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.hybinet-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--hybinet-color-text-secondary);
    transition: color 0.2s;
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.hybinet-action-btn:hover {
    color: var(--hybinet-palette-black);
}

.hybinet-action-btn svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.hybinet-action-btn span.label {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Badge del carrito */
.hybinet-cart-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background-color: var(--hybinet-color-brand-accent-web);
    color: var(--hybinet-color-text-primary);
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid var(--hybinet-palette-white);
}

/* 3. Barra Secundaria (Categorías) */
.hybinet-header__bottom {
    background-color: var(--hybinet-palette-white);
    border-bottom: 1px solid var(--hybinet-color-border-medium);
    position: relative; /* Ancla el mega menú */
    z-index: 200;
}

.hybinet-header__bottom-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
}

.hybinet-nav-categories {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 8px 0; /* Padding superior/inferior para dar espacio a la píldora */
    gap: 4px;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.hybinet-nav-categories::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.hybinet-nav-categories li {
    flex-shrink: 0;
}

.hybinet-nav-categories .nav-pill-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--hybinet-color-bg-image);
    color: var(--hybinet-color-text-primary);
    padding: 8px 16px;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600; /* Original era 600 */
    transition: background-color 0.2s;
}

.hybinet-nav-categories a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 50px;
    color: var(--hybinet-color-text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    background-color: transparent;
}

/* Hover y estados activos para escritorio */
@media (min-width: 768px) {
    .hybinet-nav-categories a:not(.nav-pill-btn):hover {
        background-color: var(--hybinet-color-bg-tertiary);
        color: var(--hybinet-color-text-primary);
    }
    
    .hybinet-nav-categories .nav-pill-btn:hover,
    .hybinet-nav-categories .nav-pill-btn.is-open {
        background-color: var(--hybinet-color-bg-tertiary);
        color: var(--hybinet-color-text-primary);
    }
}

/* Enlace promocional (Ofertas) usando la paleta oficial (color acento de la marca) */
.hybinet-nav-categories a.nav-promo {
    color: var(--hybinet-color-brand-accent);
    font-weight: 700;
}

/* ==========================================================================
   4. RESPONSIVE (MÓVIL)
========================================================================== */
@media (max-width: 767px) {
    /* Permitir que el buscador baje a la segunda línea */
    .hybinet-header__main {
        flex-wrap: wrap;
        padding: 12px 1rem;
        gap: 16px;
    }

    /* Fila superior móvil: Logo a la izquierda, Acciones a la derecha */
    .hybinet-header__logo {
        flex-grow: 1;
        display: flex;
        justify-content: flex-start; /* Logo a la izquierda en móvil */
    }

    /* Alinear barra secundaria con la principal */
    .hybinet-header__bottom-inner {
        padding: 0 1rem;
    }

    .hybinet-header__logo-text {
        font-size: 1.5rem;
    }

    /* Buscador toma el 100% de la segunda línea */
    .hybinet-header__search {
        order: 3; /* Va al final */
        flex-basis: 100%;
        max-width: 100%;
    }

    /* Ocultar textos de los botones de acción para ahorrar espacio */
    .hybinet-action-btn span.label {
        display: none;
    }

    .hybinet-action-btn svg {
        margin-bottom: 0;
    }

    .hybinet-nav-categories {
        gap: 24px;
        padding: 4px 0 0;
    }

    /* Estilos unificados para botones y enlaces en móvil */
    .hybinet-nav-categories .nav-pill-btn,
    .hybinet-nav-categories a {
        padding: 6px 0 calc(6px - 3px);
        width: auto;
        justify-content: center;
        border-radius: 0;
        background-color: transparent;
        color: var(--hybinet-color-text-secondary);
        border-bottom: 3px solid transparent;
    }

    .hybinet-nav-categories .nav-pill-btn .nav-pill-text {
        display: none;
    }
    
    .hybinet-nav-categories .nav-pill-btn svg {
        width: 22px;
        height: 22px;
    }

    /* Estados de interacción en móvil (tap/hover) */
    .hybinet-nav-categories .nav-pill-btn:hover,
    .hybinet-nav-categories .nav-pill-btn:active,
    .hybinet-nav-categories a:hover,
    .hybinet-nav-categories a:active {
        color: var(--hybinet-color-text-primary);
        border-bottom-color: var(--hybinet-color-border-soft);
    }

    /* Estado de página activa */
    .hybinet-nav-categories a.is-active {
        color: var(--hybinet-color-text-primary);
        border-bottom-color: var(--hybinet-color-brand-accent);
    }

    /* Ofertas: color verde permanente */
    .hybinet-nav-categories a.nav-promo,
    .hybinet-nav-categories a.nav-promo:hover,
    .hybinet-nav-categories a.nav-promo:active,
    .hybinet-nav-categories a.nav-promo.is-active {
        color: var(--hybinet-color-brand-accent);
    }


}
