.er-header {
    position: sticky;
    top: 0;
    z-index: 800;
    background:
        radial-gradient(
            circle at top left,
            rgba(255, 255, 255, 0.14),
            transparent 34%
        ),
        linear-gradient(135deg, var(--er-primary-dark), var(--er-primary));
    box-shadow: 0 14px 34px rgba(0, 36, 105, 0.22);
}

.er-header__inner {
    width: min(1480px, calc(100% - 32px));
    min-height: var(--er-header-height);
    margin: 0 auto;
    display: grid;

    /*
    PC:
    columna 1 = logo horizontal grande
    columna 2 = buscador
    columna 3 = carrito / usuario
    */
    grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1.25fr) minmax(
            230px,
            0.8fr
        );

    align-items: center;
    gap: 18px;
}

.er-brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
}

/*
|--------------------------------------------------------------------------
| Marca PC / Móvil
|--------------------------------------------------------------------------
*/

/* En PC ocultamos el logo pequeño */
.er-brand__logo {
    display: none;
}

/* Ya no usamos texto HTML de marca */
.er-brand__text {
    display: none;
}

/* En PC mostramos solo la imagen horizontal completa */
.er-brand__name-image {
    width: min(630px, 100%);
    min-width: 0;

    /*
    IMPORTANTE:
    Este height recorta visualmente el espacio vacío arriba/abajo
    que trae la imagen PNG.
    Si todavía ves mucho aire, baja a 68px o 64px.
    Si se corta demasiado, sube a 82px o 90px.
    */
    height: 76px;

    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}

.er-brand__name-image img {
    width: auto;
    max-width: 630px;

    /*
    Debe ser mayor que el alto del contenedor para poder recortar.
    */
    max-height: 150px;

    object-fit: contain;

    /*
    Ajustes visuales:
    - translateY mueve la imagen arriba/abajo.
    - scale agranda el contenido para compensar el espacio vacío del PNG.
    */
    transform: translateY(5px) scale(1.18);
    transform-origin: center;
}

/*
|--------------------------------------------------------------------------
| Buscador
|--------------------------------------------------------------------------
*/

.er-header__search {
    min-width: 0;
}

.er-search {
    width: min(720px, 100%);
    min-height: 48px;
    margin: 0 auto;
    padding: 5px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 16px 34px rgba(17, 24, 39, 0.18);
}

.er-search i {
    display: grid;
    place-items: center;
    color: var(--er-primary);
    font-size: 15px;
}

.er-search input {
    width: 100%;
    min-width: 0;
    height: 38px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--er-gray-900);
    font-size: 14px;
    font-weight: 800;
}

.er-search input::placeholder {
    color: var(--er-gray-400);
}

.er-search button {
    min-height: 38px;
    border: 0;
    border-radius: 999px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: linear-gradient(
        135deg,
        var(--er-accent),
        var(--er-accent-dark)
    );
    font-size: 13px;
    font-weight: 1000;
    box-shadow: 0 10px 22px rgba(var(--er-accent-rgb), 0.24);
    transition: var(--transition-normal);
}

.er-search button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(var(--er-accent-rgb), 0.28);
}

/*
|--------------------------------------------------------------------------
| Navegación header
|--------------------------------------------------------------------------
*/

.er-header__nav {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.er-header-action,
.er-google-login-btn {
    position: relative;
    min-height: 44px;
    border-radius: 999px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-size: 13px;
    font-weight: 1000;
    white-space: nowrap;
    transition: var(--transition-normal);
}

.er-header-action:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.22);
}

.er-google-login-btn {
    color: var(--er-gray-900);
    background: #ffffff;
    border-color: rgba(255, 255, 255, 0.65);
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.16);
}

.er-google-login-btn:hover {
    color: var(--er-primary);
    transform: translateY(-1px);
}

.er-google-login-btn i {
    color: #ea4335;
}

.er-cart-header-btn strong,
.er-mobile-cart strong {
    position: absolute;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--er-accent);
    font-size: 11px;
    font-weight: 1000;
    line-height: 1;
    box-shadow: 0 8px 18px rgba(var(--er-accent-rgb), 0.35);
}

.er-cart-header-btn strong {
    top: -8px;
    right: -8px;
}

.er-cart-header-btn strong[hidden],
.er-mobile-cart strong[hidden] {
    display: none !important;
}

/*
|--------------------------------------------------------------------------
| Usuario
|--------------------------------------------------------------------------
*/

.er-store-user-menu,
.vb-store-user-menu {
    position: relative;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
}

.er-store-user-btn,
.vb-store-user-btn {
    min-height: 46px;
    border: 0;
    border-radius: 999px;
    padding: 6px 12px 6px 7px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.14);
    cursor: pointer;
    transition: var(--transition-normal);
}

.er-store-user-btn:hover,
.vb-store-user-menu.is-open .er-store-user-btn,
.vb-store-user-menu.is-open .vb-store-user-btn {
    background: rgba(255, 255, 255, 0.24);
}

.er-store-user-avatar,
.vb-store-user-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 999px;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: #ffffff;
    color: var(--er-primary);
    border: 2px solid rgba(255, 255, 255, 0.45);
}

.er-store-user-avatar img,
.vb-store-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.er-store-user-meta,
.vb-store-user-meta {
    display: grid;
    gap: 1px;
    min-width: 0;
    max-width: 170px;
    text-align: left;
}

.er-store-user-meta strong,
.er-store-user-meta small,
.vb-store-user-meta strong,
.vb-store-user-meta small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.er-store-user-meta strong,
.vb-store-user-meta strong {
    color: #ffffff;
    font-size: 13px;
    font-weight: 1000;
    line-height: 1.1;
}

.er-store-user-meta small,
.vb-store-user-meta small {
    color: rgba(255, 255, 255, 0.74);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.1;
}

.er-store-user-arrow,
.vb-store-user-arrow {
    font-size: 11px;
    opacity: 0.9;
    transition: transform 0.2s ease;
}

.vb-store-user-menu.is-open .er-store-user-arrow,
.vb-store-user-menu.is-open .vb-store-user-arrow {
    transform: rotate(180deg);
}

.er-store-user-dropdown,
.vb-store-user-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 1200;
    width: min(280px, calc(100vw - 24px));
    overflow: hidden;
    border-radius: 18px;
    background: #ffffff;
    color: var(--er-gray-800);
    border: 1px solid rgba(0, 36, 105, 0.1);
    box-shadow: 0 22px 54px rgba(17, 24, 39, 0.22);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    display: block !important;
    transform: translateY(8px);
    transition:
        opacity 0.18s ease,
        visibility 0.18s ease,
        transform 0.18s ease;
}

.vb-store-user-menu.is-open .er-store-user-dropdown,
.vb-store-user-menu.is-open .vb-store-user-dropdown {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.er-store-user-dropdown::before,
.vb-store-user-dropdown::before {
    content: "";
    position: absolute;
    top: -7px;
    right: 24px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    transform: rotate(45deg);
    border-left: 1px solid rgba(0, 36, 105, 0.1);
    border-top: 1px solid rgba(0, 36, 105, 0.1);
}

.er-store-user-dropdown__head,
.vb-store-user-dropdown__head {
    padding: 16px;
    background: linear-gradient(
        135deg,
        rgba(0, 36, 105, 0.08),
        rgba(252, 14, 38, 0.04)
    );
    border-bottom: 1px solid var(--er-gray-200);
}

.er-store-user-dropdown__head strong,
.er-store-user-dropdown__head span,
.vb-store-user-dropdown__head strong,
.vb-store-user-dropdown__head span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.er-store-user-dropdown__head strong,
.vb-store-user-dropdown__head strong {
    color: var(--er-gray-900);
    font-size: 14px;
    font-weight: 1000;
}

.er-store-user-dropdown__head span,
.vb-store-user-dropdown__head span {
    margin-top: 4px;
    color: var(--er-gray-500);
    font-size: 12px;
    font-weight: 800;
}

.er-store-user-dropdown a,
.er-store-user-dropdown button,
.vb-store-user-dropdown a,
.vb-store-user-dropdown button {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 0 !important;
    padding: 12px 16px;
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    background: #ffffff !important;
    color: var(--er-gray-700) !important;
    font-size: 13px;
    font-weight: 1000;
    text-align: left;
    box-shadow: none !important;
}

.er-store-user-dropdown a:hover,
.er-store-user-dropdown button:hover,
.vb-store-user-dropdown a:hover,
.vb-store-user-dropdown button:hover {
    background: var(--er-gray-100) !important;
    color: var(--er-primary) !important;
}

.er-store-user-dropdown a i,
.er-store-user-dropdown button i,
.vb-store-user-dropdown a i,
.vb-store-user-dropdown button i {
    width: 18px;
    min-width: 18px;
    color: var(--er-primary);
    text-align: center;
}

.er-store-user-dropdown form,
.vb-store-user-dropdown form {
    margin: 0;
    border-top: 1px solid var(--er-gray-200);
}

/*
|--------------------------------------------------------------------------
| Bottom nav Android
|--------------------------------------------------------------------------
*/

.er-mobile-nav {
    display: none;
}

/*
|--------------------------------------------------------------------------
| Safari/iOS preventivo
|--------------------------------------------------------------------------
*/

.er-header,
.er-brand__logo,
.er-brand__name-image,
.er-search,
.er-header-action,
.er-google-login-btn,
.er-store-user-btn,
.er-store-user-dropdown,
.er-mobile-nav {
    -webkit-tap-highlight-color: transparent;
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
}

.er-store-user-avatar img,
.er-brand__logo img,
.er-brand__name-image img {
    -webkit-user-drag: none;
    user-select: none;
}

/*
|--------------------------------------------------------------------------
| Responsive tablet
|--------------------------------------------------------------------------
*/

@media (max-width: 1040px) {
    .er-header__inner {
        grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.2fr) auto;
    }

    .er-brand__name-image {
        width: min(420px, 100%);
        height: 68px;
    }

    .er-brand__name-image img {
        max-width: 420px;
        max-height: 130px;
        transform: translateY(-5px) scale(1.16);
    }

    .er-header-action span {
        display: none;
    }
}

/*
|--------------------------------------------------------------------------
| Móvil tipo app Android
|--------------------------------------------------------------------------
*/

@media (max-width: 760px) {
    .er-header {
        position: sticky;
    }

    .er-header__inner {
        width: min(100% - 20px, 1480px);
        min-height: 116px;
        padding: 10px 0 11px;
        grid-template-columns: 1fr auto;
        gap: 9px 12px;
    }

    .er-brand {
        gap: 9px;
    }

    /*
    En móvil ocultamos el logo horizontal grande.
    */
    .er-brand__name-image {
        display: none;
    }

    /*
    En móvil mostramos solo el logo pequeño.
    */
    .er-brand__logo {
        width: 42px;
        height: 42px;
        min-width: 42px;
        border-radius: 15px;
        display: grid;
        place-items: center;
        overflow: hidden;
        background: #ffffff;
        color: var(--er-primary);
        box-shadow: 0 10px 24px rgba(17, 24, 39, 0.18);
    }

    .er-brand__logo img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        padding: 5px;
    }

    .er-brand__logo i {
        display: none;
        font-size: 20px;
    }

    .er-brand__logo--fallback i {
        display: inline-flex;
    }

    .er-header__nav {
        gap: 8px;
    }

    .er-header__search {
        grid-column: 1 / -1;
        order: 3;
    }

    .er-search {
        width: 100%;
        min-height: 44px;
        grid-template-columns: 38px minmax(0, 1fr) 42px;
        padding: 4px;
        border-radius: 18px;
        box-shadow: 0 10px 22px rgba(17, 24, 39, 0.15);
    }

    .er-search input {
        height: 36px;
        font-size: 13px;
    }

    .er-search button {
        width: 38px;
        min-width: 38px;
        height: 36px;
        min-height: 36px;
        padding: 0;
        border-radius: 14px;
    }

    .er-search button span {
        display: none;
    }

    .er-search button::before {
        content: "\f002";
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
    }

    .er-header-action,
    .er-google-login-btn {
        width: 42px;
        height: 42px;
        min-height: 42px;
        padding: 0;
        border-radius: 15px;
    }

    .er-header-action span,
    .er-google-login-btn span {
        display: none;
    }

    .er-store-user-meta,
    .vb-store-user-meta,
    .er-store-user-arrow,
    .vb-store-user-arrow {
        display: none;
    }

    .er-store-user-btn,
    .vb-store-user-btn {
        width: 42px;
        height: 42px;
        min-height: 42px;
        padding: 4px;
        border-radius: 15px;
        justify-content: center;
    }

    .er-store-user-avatar,
    .vb-store-user-avatar {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .er-store-user-dropdown,
    .vb-store-user-dropdown {
        position: fixed;
        top: 72px;
        right: 10px;
        width: min(292px, calc(100vw - 20px));
        max-height: calc(100vh - 94px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .er-store-user-dropdown a span,
    .er-store-user-dropdown button span,
    .vb-store-user-dropdown a span,
    .vb-store-user-dropdown button span {
        display: inline !important;
        white-space: nowrap;
    }

    .er-mobile-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 850;
        height: calc(var(--er-mobile-nav-height) + env(safe-area-inset-bottom));
        padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
        display: grid;

        /* Ahora son 4 botones: Inicio, Carrito, Pedidos, Salir/Login */
        grid-template-columns: repeat(4, minmax(0, 1fr));

        gap: 4px;
        background: rgba(255, 255, 255, 0.96);
        border-top: 1px solid rgba(0, 36, 105, 0.1);
        box-shadow: 0 -12px 34px rgba(17, 24, 39, 0.12);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    .er-mobile-nav__item {
        position: relative;
        border: 0;
        border-radius: 16px;
        min-width: 0;
        display: grid;
        place-items: center;
        align-content: center;
        gap: 3px;
        color: var(--er-gray-500);
        background: transparent;
        font-size: 10.5px;
        font-weight: 1000;
        line-height: 1;
    }

    .er-mobile-nav__form {
        margin: 0;
        padding: 0;
        min-width: 0;
        display: block;
    }

    .er-mobile-nav__form .er-mobile-nav__item {
        width: 100%;
        height: 100%;
    }

    .er-mobile-nav__item--logout i {
        color: var(--er-accent);
    }

    .er-mobile-nav__item i {
        color: var(--er-primary);
        font-size: 18px;
        line-height: 1;
    }

    .er-mobile-nav__item:hover,
    .er-mobile-nav__item:focus {
        color: var(--er-primary);
        background: rgba(0, 36, 105, 0.06);
    }

    .er-mobile-nav__item:active {
        transform: scale(0.98);
    }

    .er-mobile-cart strong {
        top: 5px;
        right: 24%;
        min-width: 18px;
        height: 18px;
        font-size: 10px;
    }

    /*
    En móvil la cuenta superior solo muestra foto.
    El menú no se despliega arriba porque las acciones están abajo.
    */
    .er-store-user-dropdown,
    .vb-store-user-dropdown {
        display: none !important;
    }

    .vb-store-user-menu.is-open .er-store-user-dropdown,
    .vb-store-user-menu.is-open .vb-store-user-dropdown {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

@media (max-width: 390px) {
    .er-mobile-nav__item {
        font-size: 9.5px;
    }

    .er-mobile-nav__item i {
        font-size: 17px;
    }
}
