﻿/* ============================================================
   NatuLabs - HEADER
   Nav home + sidebar -> header horizontal + iconos lupa/carrito
   ============================================================ */

/* NAV — Header propio NatuLabs (home) */
.nl-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(245, 240, 228, 0.92);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-bottom: 1px solid var(--ink-line);
}
.nl-nav__inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 18px var(--gutter);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 40px;
}
.nl-nav__logo img {
    max-height: 44px;
    width: auto;
    transition: transform .3s ease;
}
.nl-nav__logo:hover img { transform: scale(1.02); }

.nl-nav__links {
    display: flex;
    justify-content: center;
    gap: 40px;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.02em;
}
.nl-nav__links a {
    position: relative;
    color: var(--ink-soft) !important;
    transition: color .3s;
    padding: 6px 0;
}
.nl-nav__links a::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 0; height: 1px;
    background: var(--leaf);
    transition: width .35s ease;
}
.nl-nav__links a:hover {
    color: var(--ink) !important;
}
.nl-nav__links a:hover::after { width: 100%; }

.nl-nav__meta {
    display: flex;
    align-items: center;
    gap: 16px;
}
.nl-nav__cart {
    position: relative;
    color: var(--ink) !important;
    padding: 8px;
    transition: color .3s;
}
.nl-nav__cart:hover { color: var(--leaf) !important; }
.nl-nav__cart-count {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--leaf);
    color: var(--cream);
    font-size: 10px;
    font-weight: 600;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nl-nav__burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    width: 32px;
    padding: 6px;
}
.nl-nav__burger span {
    width: 100%;
    height: 1.5px;
    background: var(--ink);
    transition: transform .3s, opacity .3s;
}

@media (max-width: 880px) {
    .nl-nav__inner { grid-template-columns: auto auto auto; }
    .nl-nav__links { display: none; }
    .nl-nav__burger { display: flex; }
    .nl-nav.is-open .nl-nav__links {
        display: flex !important;
        position: fixed;
        top: 70px;
        left: 0; right: 0; bottom: 0;
        flex-direction: column;
        gap: 0;
        padding: 40px var(--gutter);
        background: var(--cream);
        font-size: 28px;
        font-family: var(--serif);
        font-weight: 400;
        z-index: 99;
    }
    .nl-nav.is-open .nl-nav__links a {
        padding: 18px 0;
        border-bottom: 1px solid var(--ink-line);
        color: var(--ink) !important;
    }
}


   FIX MOBILE 1 · Iconos sticky del header utilities (lupa/carrito/burger)
   Que se integren al header horizontal, no floten gigantes
   ============================================================ */

@media (max-width: 768px) {
    /* El bloque que contiene lupa/carrito/burger en mobile */
    .js-head-main,
    .head-main,
    header.js-head-main {
        position: sticky !important;
        top: 0 !important;
        background: var(--cream) !important;
        z-index: 200 !important;
        padding: 10px 14px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        border-bottom: 1px solid rgba(28, 26, 22, 0.06) !important;
        box-shadow: 0 1px 6px -2px rgba(28, 26, 22, 0.05) !important;
    }
    /* Iconos: más chicos y discretos */
    .js-head-main button,
    .js-head-main a[class*="icon"],
    .js-head-main [class*="icon-circle"],
    .head-main button,
    .head-main a[class*="icon"] {
        width: 36px !important;
        height: 36px !important;
        padding: 7px !important;
        background: transparent !important;
        border: none !important;
        border-radius: 50% !important;
        color: var(--ink) !important;
        transition: background .25s ease !important;
    }
    .js-head-main button:hover,
    .head-main button:hover {
        background: rgba(28, 26, 22, 0.06) !important;
    }
    .js-head-main svg,
    .head-main svg {
        width: 20px !important;
        height: 20px !important;
        max-width: 20px !important;
        max-height: 20px !important;
        fill: currentColor !important;
        color: var(--ink) !important;
    }
    /* Badge del carrito (número de items) */
    .js-head-main [class*="badge"],
    .js-head-main [class*="count"],
    .head-main [class*="badge"] {
        background: var(--leaf) !important;
        color: var(--cream) !important;
        font-size: 9px !important;
        min-width: 16px !important;
        height: 16px !important;
        line-height: 16px !important;
    }
}


/* ============================================================
   FIX 4 · Sidebar vertical → Header horizontal
   La .sidebar-content se transforma en barra horizontal arriba
   ============================================================ */

/* Sacar el sidebar de su posición fija lateral y convertirlo en bar horizontal */
.sidebar-content,
.sidebar-content-transparent,
body .sidebar-content {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    background: var(--cream) !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(28, 26, 22, 0.08) !important;
    padding: 18px clamp(20px, 4vw, 56px) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 32px !important;
    z-index: 100 !important;
    overflow: visible !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Logo a la izquierda, tamaño contenido */
.sidebar-content [class*="logo"],
.sidebar-content .header-logo,
.sidebar-content [class*="header-logo"] {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: 180px !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sidebar-content [class*="logo"] img,
.sidebar-content [class*="logo"] svg {
    max-height: 44px !important;
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
}

/* La nav scrollable area ahora es flex horizontal a la derecha */
.sidebar-content .nav-scrollable-area,
.sidebar-content .nav-with-fixed-footer,
.sidebar-content .nav-body {
    flex: 0 1 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex-direction: row !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

/* Lista de navegación: horizontal */
.sidebar-content ul,
.sidebar-content nav ul,
.sidebar-content .nav-body ul {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: clamp(20px, 3vw, 36px) !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-wrap: nowrap !important;
}

.sidebar-content ul li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    border: none !important;
    width: auto !important;
}

/* Links del menú: tipografía editorial */
.sidebar-content ul li a,
.sidebar-content nav a {
    font-family: var(--sans) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: 0.16em !important;
    text-transform: uppercase !important;
    color: var(--ink) !important;
    text-decoration: none !important;
    padding: 8px 0 !important;
    border: none !important;
    background: transparent !important;
    transition: color .3s ease !important;
    display: inline-block !important;
    line-height: 1 !important;
}

.sidebar-content ul li a:hover {
    color: var(--leaf) !important;
}

/* Sub-items de navegación (como "Magnesio" dentro de "Productos") - dropdown */
.sidebar-content ul li ul {
    display: none !important;
}

/* Eliminar botones de "ingresar / crear cuenta" del sidebar (van al header utilities) */
.sidebar-content [class*="footer"],
.sidebar-content .nav-footer,
.sidebar-content [class*="login"],
.sidebar-content [class*="register"],
.sidebar-content [class*="account"]:not(a),
.sidebar-content [class*="ingresar"],
.sidebar-content [class*="lang-"],
.sidebar-content [class*="social"]:not(footer *) {
    display: none !important;
}

/* Body ya no tiene padding-left para sidebar lateral */
body,
body.template-home,
body.template-product,
body.template-category,
body.template-page,
body.template-search,
body.template-cart {
    padding-left: 0 !important;
}

.main-content,
body .main-content {
    margin-left: 0 !important;
    padding-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Mobile: hamburguesa siempre visible, menú colapsa */
@media (max-width: 768px) {
    .sidebar-content {
        padding: 14px 18px !important;
        gap: 16px !important;
    }
    .sidebar-content [class*="logo"] img {
        max-height: 36px !important;
    }
    .sidebar-content .nav-scrollable-area,
    .sidebar-content .nav-with-fixed-footer {
        display: none !important;
    }
}

/* Logo siempre clickeable, asegurar que envuelve un <a> al home */
.sidebar-content [class*="logo"] a {
    display: inline-block !important;
    text-decoration: none !important;
}

/* ============================================================
   FIX · Sidebar-content-transparent con fondo verde en PDP mobile
   El tema agrega .sidebar-content-transparent en home/product que
   muestra un banner verde gigante con logo. Forzar transparente.
   ============================================================ */
.sidebar-content.sidebar-content-transparent,
body.template-product .sidebar-content,
body.template-product .sidebar-content-transparent,
body.template-home .sidebar-content,
body.template-home .sidebar-content-transparent {
    background: var(--cream) !important;
    background-color: var(--cream) !important;
    background-image: none !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
}

/* Mobile: ocultar TODO el sidebar-content (incluyendo el variant transparent) */
@media (max-width: 768px) {
    html body .sidebar-content,
    html body .sidebar-content.sidebar-content-transparent,
    html body div.sidebar-content,
    html body div.sidebar-content-transparent,
    html body[class*="template-"] .sidebar-content,
    html body[class*="template-"] .sidebar-content-transparent {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        width: 0 !important;
        max-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -99999px !important;
        top: -99999px !important;
        opacity: 0 !important;
        z-index: -1 !important;
        background: transparent !important;
    }
}

/* ============================================================
   FIX MOBILE · Logo NatuLabs en .nl-mobile-logo
   El .nl-mobile-logo img estaba renderizando 400x400 porque
   el CSS no estaba pegando — selector forzado con html body
   ============================================================ */

html body .nl-mobile-logo {
    display: none;
}

@media (max-width: 768px) {
    html body header.js-head-main,
    html body .js-head-main {
        background: var(--cream) !important;
        background-color: var(--cream) !important;
        background-image: none !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 200 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 12px !important;
        padding: 12px 16px !important;
        min-height: 108px !important;
        max-height: 120px !important;
        border-bottom: 1px solid rgba(28, 26, 22, 0.06) !important;
        box-shadow: 0 1px 6px -2px rgba(28, 26, 22, 0.05) !important;
    }

    html body .nl-mobile-logo {
        display: flex !important;
        align-items: center !important;
        flex: 0 0 auto !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: 260px !important;
        max-height: 96px !important;
        overflow: hidden !important;
    }
    html body .nl-mobile-logo a {
        display: inline-block !important;
        line-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    html body .nl-mobile-logo img {
        height: 88px !important;
        max-height: 88px !important;
        width: auto !important;
        max-width: 240px !important;
        display: block !important;
        object-fit: contain !important;
    }

    /* Iconos del header derecha (lupa/carrito/burger) */
    html body .js-head-main .utilities-container,
    html body .js-head-main [class*="utilities"] {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        flex: 0 0 auto !important;
        background: transparent !important;
    }

    html body .js-head-main button,
    html body .js-head-main a:not(.nl-mobile-logo a) {
        background: transparent !important;
        border: none !important;
        padding: 8px !important;
        width: 36px !important;
        height: 36px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: var(--ink) !important;
        border-radius: 50% !important;
    }

    html body .js-head-main svg {
        width: 20px !important;
        height: 20px !important;
        max-width: 20px !important;
        max-height: 20px !important;
        color: var(--ink) !important;
        fill: currentColor !important;
    }
}

/* ============================================================
   FIX · Botón "Comprar" sticky en mobile (PDP) — eliminar
   El tema Atlántico tiene .js-fixed-product-form que persigue al scroll
   ============================================================ */
.js-fixed-product-form,
.js-fixed-product-form-placeholder,
.js-product-form.js-fixed-product-form,
[class*="fixed-product-form"]:not(form#product_form),
[class*="sticky-product-form"],
[class*="sticky-add-to-cart"] {
    position: static !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    box-shadow: none !important;
    z-index: auto !important;
}

/* Si el form principal recibe la clase fixed por JS, anularlo */
body.template-product form#product_form.js-fixed-product-form-active,
body.template-product .js-fixed-product-form-active {
    position: static !important;
    transform: none !important;
}

/* Mobile: ocultar cualquier barra fija de "agregar al carrito" que aparece al scroll */
@media (max-width: 768px) {
    body.template-product .js-fixed-product-form-placeholder,
    body.template-product [class*="fixed-bottom-cart"],
    body.template-product [class*="floating-cart"],
    body.template-product [class*="sticky-cart"],
    body.template-product [class*="bottom-cart-bar"] {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        left: -99999px !important;
    }
}


/* ============================================================
   FIX DESKTOP · Iconos del header (lupa + carrito)
   ----------------------------------------------------------------------
   Mismo estilo que mobile: planos, transparentes, color ink.
   Sin círculos, sin badges turquesa heredados del theme.
   ============================================================ */
@media (min-width: 769px) {
    /* Wrapper de utilities */
    html body .utilities-container,
    html body [class*="utilities-container"] {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        background: transparent !important;
    }

    html body .utilities-item {
        background: transparent !important;
        margin: 0 !important;
        padding: 0 !important;
        list-style: none !important;
    }

    /* Íconos planos sin border, sin background */
    html body .utilities-link,
    html body .utilities-item > a,
    html body .js-toggle-search,
    html body .js-toggle-cart,
    html body .cart-summary > a,
    html body #ajax-cart > a {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important;
        height: 40px !important;
        padding: 8px !important;
        background: transparent !important;
        background-color: transparent !important;
        border: none !important;
        border-radius: 50% !important;
        color: var(--ink) !important;
        transition: background .25s ease, color .25s ease !important;
        position: relative !important;
        text-decoration: none !important;
        box-shadow: none !important;
    }

    /* Hover sutil: solo un fondo ligero */
    html body .utilities-link:hover,
    html body .utilities-item > a:hover,
    html body .js-toggle-search:hover,
    html body .js-toggle-cart:hover,
    html body .cart-summary > a:hover {
        background: rgba(28, 26, 22, 0.06) !important;
        color: var(--ink) !important;
    }

    html body .utilities-link svg,
    html body .utilities-item svg,
    html body .cart-summary svg,
    html body .js-toggle-search svg,
    html body .js-toggle-cart svg {
        width: 20px !important;
        height: 20px !important;
        fill: currentColor !important;
        color: inherit !important;
    }

    /* Badge del carrito: chico, lime, sin turquesa */
    html body .cart-widget-amount,
    html body .js-cart-widget-amount,
    html body [class*="cart-widget-amount"] {
        background: var(--lime) !important;
        background-color: var(--lime) !important;
        color: var(--ink) !important;
        font-family: var(--sans) !important;
        font-size: 10px !important;
        font-weight: 700 !important;
        min-width: 16px !important;
        height: 16px !important;
        line-height: 16px !important;
        padding: 0 4px !important;
        border-radius: 999px !important;
        border: 2px solid var(--cream) !important;
        position: absolute !important;
        top: 2px !important;
        right: 2px !important;
        text-align: center !important;
        letter-spacing: 0 !important;
        box-shadow: none !important;
    }

    /* Reset wrapper del carrito */
    html body #ajax-cart,
    html body .cart-summary {
        background: transparent !important;
        background-color: transparent !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
}


/* ============================================================
   FIX DESKTOP · Banda verde del .head-main en PDP/category/etc.
   ----------------------------------------------------------------------
   En desktop, en templates que NO son home, el .head-main aparece como
   una banda horizontal con fondo ink (verde oscuro) arriba de todo,
   con la lupa+carrito flotando dentro. No queremos esa banda — queremos
   que el header sea invisible y los íconos se posicionen como flotantes
   arriba a la derecha sobre el contenido cream.
   ============================================================ */
@media (min-width: 769px) {
    /* Header invisible: sin altura, sin background, sin bordes */
    html body:not(.template-home) header.js-head-main,
    html body:not(.template-home) .js-head-main,
    html body:not(.template-home) .head-main {
        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
        border: none !important;
        box-shadow: none !important;
        min-height: 0 !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        position: relative !important;
        z-index: 100 !important;
    }

    /* Posicionamos las utilities (lupa+carrito) flotantes arriba a la derecha */
    html body:not(.template-home) .js-head-main .utilities-container,
    html body:not(.template-home) .head-main .utilities-container,
    html body:not(.template-home) header.js-head-main .utilities-container {
        position: absolute !important;
        top: 24px !important;
        right: clamp(20px, 4vw, 56px) !important;
        z-index: 150 !important;
        background: transparent !important;
        background-color: transparent !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }

    /* El sidebar (.sidebar-content) tiene el logo NatuLabs.
       Lo dejamos fluido sin que la utilities-container interfiera. */
    html body:not(.template-home) .sidebar-content {
        background: var(--cream) !important;
        position: relative !important;
        z-index: 10 !important;
    }

    /* Hamburger menu: ocultar en desktop (es solo para mobile) */
    html body:not(.template-home) .js-hamburger-menu,
    html body:not(.template-home) .js-head-main .js-hamburger-menu {
        display: none !important;
    }
}


/* ============================================================
   §HEADER HOME · Sticky transparente sobre hero, sólido al scrollear
   ----------------------------------------------------------------------
   En desktop home: el .sidebar-content actúa como header sticky.
   - Estado inicial (sobre hero): fondo transparente, sin borde.
   - Estado scrolled: fondo cream + borde inferior + sombra sutil.
   - Las utilities (lupa+carrito de .js-head-main) se posicionan absolute
     dentro del mismo plano visual a la derecha.
   - El "Inicio" del nav se oculta (redundante en home).
   ============================================================ */
@media (min-width: 769px) {
    /* sidebar-content del home: sticky transparente sobre hero */
    html body.template-home .sidebar-content {
        position: sticky !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        z-index: 200 !important;

        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
        border: none !important;
        border-bottom: 1px solid transparent !important;
        box-shadow: none !important;

        padding: 14px clamp(20px, 4vw, 56px) !important;

        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-direction: row !important;
        gap: 32px !important;

        transition: background-color .35s ease,
                    border-color .35s ease,
                    box-shadow .35s ease,
                    padding .35s ease !important;
    }

    /* Estado scrolled: lo activamos cuando el body tiene la clase
       .nl-scrolled (la agrega un pequeño JS en home.tpl).
       Fallback: si JS no carga, queda transparente — no se rompe nada. */
    html body.template-home.nl-scrolled .sidebar-content {
        background: rgba(245, 240, 228, 0.94) !important;
        background-color: rgba(245, 240, 228, 0.94) !important;
        border-bottom-color: rgba(28, 26, 22, 0.10) !important;
        box-shadow: 0 1px 12px -4px rgba(28, 26, 22, 0.08) !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
        backdrop-filter: blur(14px) saturate(140%) !important;
        -webkit-backdrop-filter: blur(14px) saturate(140%) !important;
    }

    /* Logo del header en home: tamaño contenido */
    html body.template-home .sidebar-content [class*="logo"] img {
        max-height: 42px !important;
        transition: max-height .35s ease !important;
    }
    html body.template-home.nl-scrolled .sidebar-content [class*="logo"] img {
        max-height: 36px !important;
    }

    /* Ocultar "Inicio" del nav en home (redundante) */
    html body.template-home .sidebar-content ul li a[href="/"]:not([class*="logo"]),
    html body.template-home .sidebar-content ul li a[href$="/inicio/"] {
        display: none !important;
    }
    html body.template-home .sidebar-content ul li:has(> a[href="/"]) {
        display: none !important;
    }

    /* El js-head-main en home: lo convertimos en wrapper invisible
       y lo posicionamos sobre el sidebar-content para que las utilities
       (lupa+carrito) queden a la derecha del header */
    html body.template-home header.js-head-main,
    html body.template-home .js-head-main,
    html body.template-home .head-main {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 0 !important;
        min-height: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        z-index: 250 !important;
        overflow: visible !important;
        pointer-events: none !important;
    }

    html body.template-home .js-head-main .utilities-container {
        position: absolute !important;
        top: 14px !important;
        right: clamp(20px, 4vw, 56px) !important;
        z-index: 260 !important;
        pointer-events: auto !important;
        background: transparent !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 0 !important;
        margin: 0 !important;
        transition: top .35s ease !important;
    }

    html body.template-home.nl-scrolled .js-head-main .utilities-container {
        top: 10px !important;
    }

    /* Hamburger del js-head-main: solo mobile */
    html body.template-home .js-head-main .js-hamburger-menu,
    html body.template-home .js-hamburger-menu {
        display: none !important;
    }

    /* Ocultar el .nl-mobile-logo en desktop home (ya tenemos logo en sidebar) */
    html body.template-home .nl-mobile-logo {
        display: none !important;
    }
}

/* En mobile home, el sidebar-content ya está oculto (regla global mobile en línea ~378).
   El js-head-main mobile sigue siendo el header. No tocamos nada acá. */
