/**
 * Header personalizado - BeachHome
 *
 * Estilos para el header standalone de paginas WooCommerce.
 * Replica el diseno de 4 widgets de Elementor en CSS puro.
 *
 * Estructura:
 * - Barra 1: Marquee de anuncios (#0E7C7B)
 * - Barra 2: Logo + Buscador + Iconos (blanco)
 * - Barra 3: Navegacion por categorias (#1B3A4B)
 *
 * @package HelloElementorChild_BeachHome
 * @since   1.0.0
 */


/* ==========================================================================
   VARIABLES CSS - Definidas en global.css (no redeclarar aqui)
   ========================================================================== */


/* ==========================================================================
   HEADER CONTENEDOR GLOBAL
   ========================================================================== */

.bh-hdr {
    position: relative;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}


/* ==========================================================================
   BARRA 1: ANNOUNCEMENT MARQUEE
   ========================================================================== */

.bh-hdr-marquee {
    background: linear-gradient(135deg, var(--bh-primary), var(--bh-primary-dark));
    overflow: hidden;
    white-space: nowrap;
    height: 36px;
    display: flex;
    align-items: center;
    position: relative;
}

.bh-hdr-marquee-track {
    display: inline-flex;
    align-items: center;
    animation: marquee-scroll 35s linear infinite;
    will-change: transform;
}

.bh-hdr-marquee-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--bh-bg-white);
    font-family: var(--bh-font-secondary);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    padding: 0 12px;
    white-space: nowrap;
}

.bh-hdr-marquee-item i {
    font-size: 13px;
}

.bh-hdr-marquee-sep {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    font-weight: 300;
    padding: 0 4px;
}

/* Animacion del marquee: desplaza la mitad del track (contenido duplicado) */
@keyframes marquee-scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .bh-hdr-marquee-track {
        animation-play-state: paused;
    }
}


/* ==========================================================================
   BARRA 2: LOGO + SEARCH + ICONS
   ========================================================================== */

.bh-hdr-main {
    background: var(--bh-bg-white);
    border-bottom: 1px solid var(--bh-border);
}

.bh-hdr-main-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 30px;
    gap: 24px;
}


/* --------------------------------------------------------------------------
   Logo
   -------------------------------------------------------------------------- */

.bh-hdr-logo {
    display: inline-flex;
    align-items: center;
    gap: 0;
    text-decoration: none;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.bh-hdr-logo:hover {
    opacity: 0.85;
}

.bh-hdr-logo-part1,
.bh-hdr-logo-part2 {
    font-family: var(--bh-font-primary);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--bh-secondary);
    line-height: 1;
    transition: color 0.2s ease;
}

.bh-hdr-logo:hover .bh-hdr-logo-part1,
.bh-hdr-logo:hover .bh-hdr-logo-part2 {
    color: var(--bh-primary);
}

.bh-hdr-logo-img {
    max-height: 45px;
    width: auto;
    display: block;
}

.bh-drawer-logo-img {
    max-height: 32px;
    width: auto;
    display: block;
}

.bh-hdr-logo-bar {
    display: inline-block;
    width: 3px;
    height: 28px;
    background: var(--bh-primary);
    margin: 0 8px;
    border-radius: 2px;
    flex-shrink: 0;
}


/* --------------------------------------------------------------------------
   Search Bar
   -------------------------------------------------------------------------- */

.bh-hdr-search {
    position: relative;
    flex: 1;
    max-width: 620px;
    display: flex;
    align-items: center;
}

.bh-hdr-search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: var(--bh-text-light);
    pointer-events: none;
    z-index: 2;
    transition: color 0.2s ease;
}

.bh-hdr-search-input {
    width: 100%;
    padding: 12px 130px 12px 48px;
    border: 2px solid var(--bh-border);
    border-radius: 50px;
    background: var(--bh-bg-light);
    font-family: var(--bh-font-secondary);
    font-size: 14px;
    color: var(--bh-text-dark);
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.bh-hdr-search-input::placeholder {
    color: var(--bh-text-light);
    font-weight: 400;
}

.bh-hdr-search-input:focus {
    border-color: var(--bh-primary);
    background: var(--bh-bg-white);
    box-shadow: 0 0 0 3px rgba(var(--bh-primary-rgb), 0.12);
}

.bh-hdr-search-input:focus + .bh-hdr-search-icon,
.bh-hdr-search-input:focus ~ .bh-hdr-search-icon {
    color: var(--bh-primary);
}

/* Nota: El selector anterior no funciona porque el icono esta antes del input
   en el DOM. Se resuelve con :has() o reordenando. Usamos :focus-within. */
.bh-hdr-search:focus-within .bh-hdr-search-icon {
    color: var(--bh-primary);
}

.bh-hdr-search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: var(--bh-primary);
    color: var(--bh-bg-white);
    border: none;
    border-radius: 50px;
    font-family: var(--bh-font-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    z-index: 2;
}

.bh-hdr-search-btn:hover {
    background: var(--bh-primary-dark);
    box-shadow: 0 2px 8px rgba(var(--bh-primary-rgb), 0.35);
}

.bh-hdr-search-btn i {
    font-size: 13px;
}


/* --------------------------------------------------------------------------
   Icons (Llamar, WhatsApp, Cuenta, Carrito)
   -------------------------------------------------------------------------- */

.bh-hdr-icons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.bh-hdr-icon-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 12px;
    text-decoration: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.bh-hdr-icon-link:hover {
    background: var(--bh-primary-hover-bg);
}

.bh-hdr-icon-link i {
    font-size: 22px;
    color: var(--bh-secondary);
    transition: color 0.2s ease;
    line-height: 1;
}

.bh-hdr-icon-link:hover i {
    color: var(--bh-primary);
}

.bh-hdr-icon-label {
    font-family: var(--bh-font-secondary);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--bh-text-gray);
    margin-top: 4px;
    line-height: 1;
    letter-spacing: 0.3px;
}

/* Badge del carrito */
.bh-hdr-badge {
    position: absolute;
    top: 2px;
    right: 8px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bh-primary);
    color: var(--bh-bg-white);
    font-family: var(--bh-font-secondary);
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    line-height: 1;
}


/* ==========================================================================
   BARRA 3: MENU PRINCIPAL (wp_nav_menu)
   ========================================================================== */

.bh-hdr-nav {
    background: var(--bh-secondary);
    width: 100%;
}

.bh-hdr-nav-inner {
    display: flex;
    justify-content: center;
    align-items: stretch;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

/* Reset del ul generado por wp_nav_menu */
.bh-hdr-menu {
    display: flex;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Items del menu */
.bh-hdr-menu > li {
    position: relative;
}

.bh-hdr-menu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    font-family: var(--bh-font-primary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--bh-text-white) !important;
    text-decoration: none;
    position: relative;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.bh-hdr-menu > li > a:hover,
.bh-hdr-menu > li:hover > a {
    color: var(--bh-primary-light) !important;
}

/* Underline animado al hover */
.bh-hdr-menu > li > a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: calc(100% - 40px);
    height: 2px;
    background: var(--bh-primary);
    transition: transform 0.25s ease;
    transform-origin: center;
}

.bh-hdr-menu > li > a:hover::after,
.bh-hdr-menu > li:hover > a::after {
    transform: translateX(-50%) scaleX(1);
}

/* Item activo (pagina actual) */
.bh-hdr-menu > li.current-menu-item > a,
.bh-hdr-menu > li.current-menu-parent > a,
.bh-hdr-menu > li.current-menu-ancestor > a {
    color: var(--bh-primary-light) !important;
}

.bh-hdr-menu > li.current-menu-item > a::after,
.bh-hdr-menu > li.current-menu-parent > a::after,
.bh-hdr-menu > li.current-menu-ancestor > a::after {
    transform: translateX(-50%) scaleX(1);
}

/* Flecha indicadora de submenu */
.bh-hdr-menu > li.menu-item-has-children > a::before {
    content: '\f107';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 10px;
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.bh-hdr-menu > li.menu-item-has-children:hover > a::before {
    transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   Dropdown (sub-menu)
   -------------------------------------------------------------------------- */

.bh-hdr-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--bh-bg-white);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    list-style: none;
    margin: 0;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 100;
}

.bh-hdr-menu > li:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.bh-hdr-menu .sub-menu li {
    margin: 0;
}

.bh-hdr-menu .sub-menu li a {
    display: block;
    padding: 10px 20px;
    font-family: var(--bh-font-primary);
    font-size: 13px;
    font-weight: 500;
    color: var(--bh-text-dark) !important;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}

.bh-hdr-menu .sub-menu li a:hover {
    background: rgba(var(--bh-primary-rgb), 0.06);
    color: var(--bh-primary) !important;
    padding-left: 26px;
}

.bh-hdr-menu .sub-menu li.current-menu-item a {
    color: var(--bh-primary) !important;
    font-weight: 600;
}

/* Link padre dentro del dropdown (ej: "Tienda" dentro del submenu) */
.bh-submenu-parent-link a {
    font-weight: 700 !important;
    color: var(--bh-primary) !important;
}

/* Separador visual entre link padre y categorias */
.bh-submenu-sep {
    height: 1px;
    background: var(--bh-border);
    margin: 4px 16px;
    list-style: none;
}

/* Compatibilidad con clase antigua (por si queda algun uso directo) */
.bh-hdr-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    font-family: var(--bh-font-primary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--bh-text-white) !important;
    text-decoration: none;
    white-space: nowrap;
}


/* ==========================================================================
   RESPONSIVE - TABLET (max-width: 1024px)
   ========================================================================== */

@media screen and (max-width: 1024px) {

    .bh-hdr-main-inner {
        padding: 10px 20px;
        gap: 16px;
    }

    /* Logo mas compacto */
    .bh-hdr-logo-img { max-height: 38px; }
    .bh-hdr-logo-part1,
    .bh-hdr-logo-part2 {
        font-size: 18px;
    }

    .bh-hdr-logo-bar {
        height: 22px;
        margin: 0 6px;
    }

    /* Buscador: reducir padding del boton */
    .bh-hdr-search-input {
        padding-right: 110px;
        font-size: 13px;
    }

    .bh-hdr-search-btn {
        padding: 8px 16px;
    }

    /* Iconos: reducir padding */
    .bh-hdr-icon-link {
        padding: 6px 10px;
    }

    .bh-hdr-icon-link i {
        font-size: 20px;
    }

    /* Nav: permitir scroll */
    .bh-hdr-nav-inner {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .bh-hdr-nav-inner::-webkit-scrollbar {
        display: none;
    }

    .bh-hdr-menu > li > a {
        padding: 12px 16px;
        font-size: 12px;
    }
}


/* ==========================================================================
   HAMBURGER BUTTON (oculto en desktop, visible en mobile via media query)
   ========================================================================== */

.bh-hdr-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: none;
    border: none;
    cursor: pointer;
    order: 0;
    flex-shrink: 0;
}

.bh-hdr-hamburger span {
    display: block;
    width: 100%;
    height: 2.5px;
    background: var(--bh-secondary);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}


/* ==========================================================================
   MOBILE DRAWER - Base (oculto en desktop)
   ========================================================================== */

.bh-mobile-drawer {
    display: none;
}


/* ==========================================================================
   RESPONSIVE - MOBILE (max-width: 768px)
   ========================================================================== */

@media screen and (max-width: 768px) {

    .bh-hdr-main-inner {
        flex-wrap: wrap;
        padding: 10px 15px;
        gap: 10px;
    }

    /* Logo y iconos en la misma linea */
    .bh-hdr-logo {
        order: 1;
    }

    .bh-hdr-icons {
        order: 2;
        gap: 2px;
    }

    /* Buscador ocupa todo el ancho en segunda linea */
    .bh-hdr-search {
        order: 3;
        max-width: 100%;
        flex-basis: 100%;
    }

    /* Logo mas pequeno */
    .bh-hdr-logo-img { max-height: 34px; }
    .bh-hdr-logo-part1,
    .bh-hdr-logo-part2 {
        font-size: 16px;
    }

    .bh-hdr-logo-bar {
        height: 20px;
        margin: 0 5px;
    }

    /* Buscador: solo icono en el boton */
    .bh-hdr-search-input {
        padding: 10px 52px 10px 42px;
        font-size: 13px;
    }

    .bh-hdr-search-icon {
        left: 16px;
        font-size: 14px;
    }

    .bh-hdr-search-btn {
        padding: 8px 14px;
    }

    .bh-hdr-search-btn-text {
        display: none;
    }

    /* Iconos: sin labels */
    .bh-hdr-icon-label {
        display: none;
    }

    .bh-hdr-icon-link {
        padding: 8px 10px;
        border-radius: 8px;
    }

    .bh-hdr-icon-link i {
        font-size: 20px;
    }

    .bh-hdr-badge {
        top: 0;
        right: 4px;
        width: 16px;
        height: 16px;
        font-size: 9px;
    }

    /* Marquee mas compacto */
    .bh-hdr-marquee {
        height: 32px;
    }

    .bh-hdr-marquee-item {
        font-size: 12px;
        padding: 0 10px;
    }

    /* Ocultar barra de nav horizontal en mobile */
    .bh-hdr-nav {
        display: none;
    }

    /* Mostrar hamburger en mobile */
    .bh-hdr-hamburger {
        display: flex;
    }
}


/* ==========================================================================
   RESPONSIVE - MOBILE PEQUENO (max-width: 480px)
   ========================================================================== */

@media screen and (max-width: 480px) {

    .bh-hdr-main-inner {
        padding: 8px 10px;
        gap: 8px;
    }

    .bh-hdr-logo-part1,
    .bh-hdr-logo-part2 {
        font-size: 14px;
        letter-spacing: 0.5px;
    }

    .bh-hdr-logo-bar {
        height: 18px;
        width: 2px;
        margin: 0 4px;
    }

    .bh-hdr-icon-link {
        padding: 6px 8px;
    }

    .bh-hdr-icon-link i {
        font-size: 18px;
    }

    .bh-hdr-search-input {
        padding: 9px 48px 9px 38px;
        font-size: 12px;
    }

    .bh-hdr-search-btn {
        padding: 7px 12px;
    }
}


/* ==========================================================================
   MOBILE DRAWER - Responsive (max-width: 768px)
   ========================================================================== */

@media screen and (max-width: 768px) {

    .bh-mobile-drawer {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10000;
        pointer-events: none;
        visibility: hidden;
        transition: visibility 0.3s;
    }

    .bh-mobile-drawer.bh-drawer-open {
        pointer-events: auto;
        visibility: visible;
    }

    /* Backdrop oscuro */
    .bh-mobile-drawer::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .bh-mobile-drawer.bh-drawer-open::before {
        opacity: 1;
    }

    /* Panel que se desliza */
    .bh-drawer-panel {
        position: absolute;
        top: 0;
        left: 0;
        width: 300px;
        max-width: 85vw;
        height: 100%;
        background: var(--bh-bg-white);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        z-index: 1;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    .bh-mobile-drawer.bh-drawer-open .bh-drawer-panel {
        transform: translateX(0);
    }

    /* Cabecera del drawer */
    .bh-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid var(--bh-border);
        flex-shrink: 0;
    }

    .bh-drawer-logo {
        display: inline-flex;
        align-items: center;
    }

    .bh-drawer-logo .bh-hdr-logo-part1,
    .bh-drawer-logo .bh-hdr-logo-part2 {
        font-size: 16px;
    }

    .bh-drawer-logo .bh-hdr-logo-bar {
        height: 18px;
        margin: 0 5px;
    }

    .bh-drawer-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: none;
        border: 1px solid var(--bh-border);
        border-radius: 8px;
        cursor: pointer;
        color: var(--bh-text-gray);
        font-size: 16px;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .bh-drawer-close:hover {
        background: var(--bh-bg-light);
        color: var(--bh-primary);
    }

    /* Menu dentro del drawer */
    .bh-drawer-nav {
        flex: 1;
        padding: 8px 0;
        overflow-y: auto;
    }

    .bh-drawer-menu {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .bh-drawer-menu > li {
        position: relative;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .bh-drawer-menu > li > a {
        display: block;
        padding: 14px 20px;
        font-family: var(--bh-font-primary);
        font-size: 15px;
        font-weight: 600;
        color: var(--bh-text-dark) !important;
        text-decoration: none;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .bh-drawer-menu > li > a:hover {
        background: rgba(var(--bh-primary-rgb), 0.05);
        color: var(--bh-primary) !important;
    }

    .bh-drawer-menu > li.current-menu-item > a,
    .bh-drawer-menu > li.current-menu-ancestor > a {
        color: var(--bh-primary) !important;
    }

    /* Item con hijos: espacio para toggle */
    .bh-drawer-menu > li.menu-item-has-children > a {
        padding-right: 56px;
    }

    /* Boton toggle del accordion */
    .bh-drawer-toggle {
        position: absolute;
        top: 0;
        right: 0;
        width: 50px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        border-left: 1px solid rgba(0, 0, 0, 0.06);
        cursor: pointer;
        color: var(--bh-text-light);
        font-size: 12px;
        transition: color 0.15s ease, transform 0.25s ease;
    }

    .bh-drawer-toggle:hover {
        color: var(--bh-primary);
    }

    .bh-drawer-toggle.bh-drawer-sub-open i {
        transform: rotate(180deg);
    }

    /* Sub-menu (oculto por defecto) */
    .bh-drawer-menu .sub-menu {
        list-style: none;
        margin: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        background: var(--bh-bg-light);
        transition: max-height 0.3s ease;
    }

    .bh-drawer-menu .sub-menu.bh-drawer-sub-open {
        max-height: 600px;
    }

    .bh-drawer-menu .sub-menu li a {
        display: block;
        padding: 11px 20px 11px 32px;
        font-family: var(--bh-font-primary);
        font-size: 14px;
        font-weight: 500;
        color: var(--bh-text-gray) !important;
        text-decoration: none;
        transition: color 0.15s ease, padding-left 0.15s ease;
    }

    .bh-drawer-menu .sub-menu li a:hover {
        color: var(--bh-primary) !important;
        padding-left: 38px;
    }

    /* Link padre dentro del sub-menu (ej: "Ver toda la Tienda") */
    .bh-drawer-parent-link a {
        color: var(--bh-primary) !important;
        font-weight: 600 !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .bh-drawer-parent-link a i {
        margin-right: 6px;
        font-size: 13px;
    }

    /* Contacto rapido al fondo */
    .bh-drawer-contact {
        display: flex;
        gap: 10px;
        padding: 16px 20px;
        border-top: 1px solid var(--bh-border);
        flex-shrink: 0;
    }

    .bh-drawer-contact-link {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 10px;
        border-radius: 8px;
        font-family: var(--bh-font-primary);
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        color: var(--bh-bg-white) !important;
        background: var(--bh-secondary);
        transition: background 0.15s ease;
    }

    .bh-drawer-contact-link:hover {
        background: var(--bh-text-dark);
    }

    .bh-drawer-whatsapp {
        background: #25D366;
    }

    .bh-drawer-whatsapp:hover {
        background: #1DA851;
    }
}
