/*
 * Cabecera adaptativa de Club Marcas.
 * Se carga después del CSS personalizado para proteger la estructura,
 * manteniendo colores, logotipo y contenido configurables por servicio.
 */

.club-adaptive-header {
    position: relative !important;
    top: auto !important;
    z-index: 100;
    width: 100%;
    min-height: 76px;
    background: var(--color01);
}

.club-adaptive-header,
.club-adaptive-header * {
    box-sizing: border-box;
}

.club-adaptive-header .container {
    width: calc(100% - 32px);
    max-width: 1600px !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
    margin-right: auto !important;
    margin-left: auto !important;
}

.club-adaptive-header .header-content,
.club-adaptive-header .header-content > .col-12 {
    min-width: 0;
}

.club-adaptive-header .header-content {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

.club-adaptive-header .header-content > .col-12 {
    padding-right: 0 !important;
    padding-left: 0 !important;
}

.club-adaptive-header .mobile-fix-header,
.club-adaptive-header .menu-iconos-movil {
    display: none !important;
}

.club-adaptive-header a,
.club-adaptive-header button {
    -webkit-tap-highlight-color: transparent;
}

.club-adaptive-header .toggle-nav {
    appearance: none;
    border: 0;
    background: transparent;
}

.club-adaptive-header .mobile-back {
    width: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.club-adaptive-header a:focus-visible,
.club-adaptive-header button:focus-visible,
.club-adaptive-header input:focus-visible {
    outline: 2px solid var(--color03);
    outline-offset: 3px;
}

/* Cabecera de usuario identificado */
.club-member-header .content-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: center;
    gap: clamp(16px, 2vw, 36px);
    min-height: 76px;
}

.club-member-header .content-header .left-section,
.club-member-header .content-header .right-section {
    width: auto !important;
    min-width: 0;
    padding: 0 !important;
    border: 0 !important;
}

.club-member-header .header-top {
    display: flex !important;
    align-items: center;
    min-width: 0;
}

.club-member-header .header-top .brand-logo {
    position: static !important;
    left: auto !important;
    flex: 0 0 auto;
    margin: 0 clamp(18px, 2.5vw, 44px) 0 0;
    padding: 8px 0 !important;
    transform: none !important;
}

.club-member-header .header-top .brand-logo img {
    display: block;
    width: auto;
    max-width: 180px !important;
    max-height: 60px !important;
    object-fit: contain;
}

.club-member-header #main-nav {
    display: flex;
    align-items: center;
    min-width: 0;
}

.club-member-header .pixelstrap.sm-horizontal {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
}

.club-member-header .pixelstrap.sm-horizontal > li {
    flex: 0 0 auto;
}

.club-member-header .pixelstrap.sm-horizontal > li > a,
.club-member-header .pixelstrap.sm-horizontal > li > a:hover,
.club-member-header .pixelstrap.sm-horizontal > li > a:focus,
.club-member-header .pixelstrap.sm-horizontal > li > a:active {
    padding: 28px clamp(8px, 0.9vw, 16px) 28px 0 !important;
    line-height: 20px !important;
    white-space: nowrap;
}

.club-member-header .header-bottom {
    display: none !important;
}

.club-member-header .content-header .right-section {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
}

.club-member-header .lower-section.header-actions-section {
    display: flex !important;
    align-items: center;
    padding: 0 !important;
    background: transparent !important;
}

/* Acciones compartidas */
.header-actions {
    display: flex;
    align-items: center;
    gap: clamp(6px, 0.7vw, 12px);
    min-width: 0;
}

.header-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 38px;
    min-height: 38px;
    margin: 0;
    padding: 8px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color02) !important;
    font: inherit;
    line-height: 1;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.header-action:hover {
    color: var(--color03) !important;
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.header-action i {
    flex: 0 0 auto;
    color: currentColor !important;
    font-size: 19px;
}

.header-action img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.header-action-label {
    color: currentColor !important;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.header-action-value,
.header-cart-count {
    color: currentColor !important;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.header-cart-count {
    min-width: 17px;
    padding: 3px 5px;
    border-radius: 999px;
    background: var(--color03);
    color: var(--color01) !important;
    text-align: center;
}

.header-actions-desktop .header-action-label {
    display: none;
}

.header-actions-desktop .header-action-account .header-action-label,
.header-actions-desktop .header-action-logout .header-action-label {
    display: inline;
}

.header-actions-desktop .header-action-balance {
    padding-right: 6px;
    padding-left: 6px;
}

.header-action-logout {
    border: 1px solid currentColor;
}

.club-adaptive-header .header-menu-actions {
    display: none !important;
}

/* Buscador: una única instancia en el DOM */
.club-adaptive-header .header-search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.97);
}

.club-adaptive-header .header-search-overlay .closebtn {
    position: absolute;
    top: 18px;
    right: 24px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #555;
    font-size: 38px;
    line-height: 1;
    cursor: pointer;
}

.club-adaptive-header .header-search-overlay .overlay-content {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(720px, calc(100% - 32px));
    transform: translate(-50%, -50%);
}

.header-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    overflow: hidden;
    border: 1px solid #d5d9e0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 50px rgba(16, 24, 40, 0.14);
}

.header-search-form input {
    min-width: 0;
    height: 54px;
    padding: 0 18px;
    border: 0;
    background: transparent;
    color: #222;
    font-size: 16px;
}

.header-search-form button {
    border: 0;
    background: var(--color01);
    color: var(--color02);
    cursor: pointer;
}

/* Cabecera sin identificar */
.club-guest-header.header-basic {
    height: auto !important;
}

.club-guest-header .header-content > .col-12 {
    display: flex;
    align-items: center;
    min-height: 76px;
}

.club-guest-header .left-part {
    float: none !important;
    flex: 0 0 auto;
}

.club-guest-header .brand-logo {
    position: static !important;
    left: auto !important;
    margin: 0 clamp(18px, 2.5vw, 44px) 0 0;
    padding: 8px 0 !important;
    transform: none !important;
}

.club-guest-header .brand-logo img {
    display: block;
    width: auto;
    max-width: 180px !important;
    max-height: 60px !important;
    object-fit: contain;
}

.club-guest-header .nav-right {
    float: none !important;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
}

.club-guest-header #main-nav {
    min-width: 0;
}

.club-guest-header .pixelstrap.sm-horizontal {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
}

.club-guest-header .pixelstrap.sm-horizontal > li > a,
.club-guest-header .pixelstrap.sm-horizontal > li > a:hover,
.club-guest-header .pixelstrap.sm-horizontal > li > a:focus,
.club-guest-header .pixelstrap.sm-horizontal > li > a:active {
    padding: 28px clamp(8px, 0.9vw, 16px) !important;
    line-height: 20px !important;
    white-space: nowrap;
}

.club-guest-header .header-guest-actions-desktop {
    flex: 0 0 auto;
}

.club-guest-header .header-guest-actions-desktop > ul {
    display: flex;
    align-items: center;
    margin: 0;
}

.club-guest-header .header-guest-actions-desktop ul .onhover-div {
    position: relative !important;
    inset: auto !important;
    display: inline-flex !important;
    align-items: center;
    width: auto !important;
    margin: 0 0 0 8px !important;
    padding: 8px !important;
}

.club-guest-header .header-guest-actions-desktop .icon-user-top-no-login i {
    padding-top: 0;
}

.club-guest-header .header-guest-actions-desktop .hucha-ahorro-no-login svg {
    display: block;
}

/*
 * Estado compacto. JavaScript lo activa cuando las piezas dejan de caber,
 * incluso por encima del breakpoint habitual.
 */
.club-adaptive-header.is-compact .content-header {
    display: block !important;
}

.club-adaptive-header.is-compact .content-header .right-section,
.club-adaptive-header.is-compact .header-guest-actions-desktop {
    display: none !important;
}

.club-adaptive-header.is-compact .left-section,
.club-adaptive-header.is-compact .header-top {
    width: 100% !important;
}

.club-adaptive-header.is-compact .header-top,
.club-adaptive-header.is-compact .header-content > .col-12 {
    min-height: 72px;
}

.club-adaptive-header.is-compact .header-top .brand-logo,
.club-adaptive-header.is-compact .brand-logo {
    margin-right: auto;
}

.club-adaptive-header.is-compact #main-nav {
    margin-left: auto;
}

.club-adaptive-header.is-compact .toggle-nav {
    position: static !important;
    display: flex !important;
    align-items: center;
    height: 72px;
    padding: 0 4px !important;
}

.club-adaptive-header.is-compact .toggle-nav i {
    color: var(--color02) !important;
    font-size: 24px;
}

.club-adaptive-header.is-compact .pixelstrap.sm-horizontal {
    position: fixed !important;
    top: 0 !important;
    right: -410px;
    z-index: 10001;
    display: block !important;
    width: min(360px, 100vw) !important;
    height: 100vh !important;
    margin: 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.16) !important;
    border-radius: 0 !important;
    background: var(--color01) !important;
    box-shadow: -14px 0 36px rgba(0, 0, 0, 0.22);
}

.club-adaptive-header.is-compact .pixelstrap.sm-horizontal > li {
    display: block;
    width: 100%;
}

.club-adaptive-header.is-compact .pixelstrap.sm-horizontal > li > a,
.club-adaptive-header.is-compact .pixelstrap.sm-horizontal > li > a:hover,
.club-adaptive-header.is-compact .pixelstrap.sm-horizontal > li > a:focus,
.club-adaptive-header.is-compact .pixelstrap.sm-horizontal > li > a:active {
    display: block;
    width: 100%;
    padding: 12px 20px !important;
    color: var(--color02) !important;
    white-space: normal;
}

.club-adaptive-header.is-compact .mobile-back {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    min-height: 58px;
    padding: 16px 20px;
    color: var(--color02);
}

.club-adaptive-header.is-compact .header-menu-actions {
    display: block !important;
    margin-top: 8px;
    padding: 16px 14px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.club-adaptive-header.is-compact .header-actions-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.club-adaptive-header.is-compact .header-actions-menu .header-action {
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 9px 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.club-adaptive-header.is-compact .header-actions-menu .header-action-label {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.club-adaptive-header.is-compact .header-actions-menu .header-action-value {
    margin-left: auto;
}

.club-adaptive-header.is-compact .header-menu-search {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) 42px;
    overflow: hidden;
    margin-bottom: 4px;
    border-radius: 8px;
    background: #fff;
}

.club-adaptive-header.is-compact .header-menu-search input {
    min-width: 0;
    height: 42px;
    padding: 0 12px;
    border: 0;
    color: #222;
}

.club-adaptive-header.is-compact .header-menu-search button {
    border: 0;
    background: var(--color03);
    color: var(--color01);
}

@media (max-width: 1199px) {
    .club-adaptive-header {
        min-height: 72px;
    }

    .club-adaptive-header .container {
        width: calc(100% - 30px);
    }

    .club-adaptive-header .content-header {
        display: block !important;
    }

    .club-adaptive-header .content-header .right-section,
    .club-adaptive-header .header-guest-actions-desktop {
        display: none !important;
    }

    .club-adaptive-header .left-section,
    .club-adaptive-header .header-top {
        width: 100% !important;
    }

    .club-adaptive-header .header-top,
    .club-adaptive-header .header-content > .col-12 {
        min-height: 72px;
    }

    .club-adaptive-header .header-top .brand-logo,
    .club-adaptive-header .brand-logo {
        margin-right: auto;
    }

    .club-adaptive-header #main-nav {
        margin-left: auto;
    }

    .club-adaptive-header .toggle-nav {
        position: static !important;
        display: flex !important;
        align-items: center;
        height: 72px;
        padding: 0 4px !important;
    }

    .club-adaptive-header .toggle-nav i {
        color: var(--color02) !important;
        font-size: 24px;
    }

    .club-adaptive-header .pixelstrap.sm-horizontal {
        position: fixed !important;
        top: 0 !important;
        right: -410px;
        z-index: 10001;
        display: block !important;
        width: min(360px, 100vw) !important;
        height: 100vh !important;
        margin: 0 !important;
        overflow-x: hidden;
        overflow-y: auto;
        border: 0 !important;
        border-left: 1px solid rgba(255, 255, 255, 0.16) !important;
        border-radius: 0 !important;
        background: var(--color01) !important;
        box-shadow: -14px 0 36px rgba(0, 0, 0, 0.22);
    }

    .club-adaptive-header .pixelstrap.sm-horizontal > li {
        display: block;
        width: 100%;
    }

    .club-adaptive-header .pixelstrap.sm-horizontal > li > a,
    .club-adaptive-header .pixelstrap.sm-horizontal > li > a:hover,
    .club-adaptive-header .pixelstrap.sm-horizontal > li > a:focus,
    .club-adaptive-header .pixelstrap.sm-horizontal > li > a:active {
        display: block;
        width: 100%;
        padding: 12px 20px !important;
        color: var(--color02) !important;
        white-space: normal;
    }

    .club-adaptive-header .mobile-back {
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        min-height: 58px;
        padding: 16px 20px;
        color: var(--color02);
    }

    .club-adaptive-header .header-menu-actions {
        display: block !important;
        margin-top: 8px;
        padding: 16px 14px 24px;
        border-top: 1px solid rgba(255, 255, 255, 0.18);
    }

    .club-adaptive-header .header-actions-menu {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .club-adaptive-header .header-actions-menu .header-action {
        justify-content: flex-start;
        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 9px 10px;
        border: 1px solid rgba(255, 255, 255, 0.14);
    }

    .club-adaptive-header .header-actions-menu .header-action-label {
        display: block;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .club-adaptive-header .header-actions-menu .header-action-value {
        margin-left: auto;
    }

    .club-adaptive-header .header-menu-search {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: minmax(0, 1fr) 42px;
        overflow: hidden;
        margin-bottom: 4px;
        border-radius: 8px;
        background: #fff;
    }

    .club-adaptive-header .header-menu-search input {
        min-width: 0;
        height: 42px;
        padding: 0 12px;
        border: 0;
        color: #222;
    }

    .club-adaptive-header .header-menu-search button {
        border: 0;
        background: var(--color03);
        color: var(--color01);
    }
}

@media (max-width: 575px) {
    .club-adaptive-header .container {
        width: calc(100% - 24px);
    }

    .club-adaptive-header .brand-logo img,
    .club-adaptive-header .header-top .brand-logo img {
        max-width: 145px !important;
        max-height: 48px !important;
    }

    .club-adaptive-header.is-compact .header-actions-menu,
    .club-adaptive-header .header-actions-menu {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .club-adaptive-header *,
    .club-adaptive-header *::before,
    .club-adaptive-header *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
