/**
 * mobile-header.css — Header, drawer y barra inferior mobile (≤980px)
 *
 * Se encola con media="(max-width: 980px)" (ver includes/mobile-header.php).
 * El ocultamiento en desktop vive en un inline style de rodio-tokens, porque
 * este archivo completo no aplica en desktop.
 *
 * Diseño: "Mobile Responsive Home Design" (Figma Make). Teal unificado con
 * --rodio-teal; neutros en tokens.css (--rodio-ink, --rodio-surface, --rodio-border).
 */

@media (max-width: 980px) {

    /* =========================================================================
     * Header del Theme Builder de Divi → reemplazado en mobile
     * ======================================================================= */
    body.rodio-mh-active .et-l--header {
        display: none !important;
    }

    /* =========================================================================
     * HEADER
     * ======================================================================= */
    .rodio-mh {
        position: sticky;
        top: 0;
        z-index: 9990;
        background: #fff;
        border-bottom: 1px solid var(--rodio-border);
        color: var(--rodio-ink);
    }

    .rodio-mh a {
        text-decoration: none;
    }

    .rodio-mh__bar {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 16px;
    }

    .rodio-mh__icon-btn {
        position: relative;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        background: none;
        border: 0;
        border-radius: 8px;
        color: var(--rodio-gray-700);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .rodio-mh__icon-btn:active {
        background: var(--rodio-gray-100);
    }

    .rodio-mh__logo {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Especificidad 0,2,0: debe ganarle a ".woocommerce img { height:auto }"
       de WooCommerce (0,1,1), que aplica en la home porque Divi le agrega al
       body las clases woocommerce/woocommerce-page. El logo actual es de dos
       renglones (609×330) → 40px de alto ≈ 74px de ancho. */
    .rodio-mh .rodio-mh__logo-img,
    .rodio-mdrawer .rodio-mh__logo-img {
        display: block;
        width: auto;
        height: 40px;
        max-width: 170px;
        object-fit: contain;
    }

    .rodio-mh__wordmark {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 18px;
        font-weight: 700;
        letter-spacing: -0.3px;
        line-height: 1;
        color: var(--rodio-ink);
        white-space: nowrap;
    }

    .rodio-mh__wordmark-mark {
        width: 28px;
        height: 28px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 7px;
        background: linear-gradient(135deg, var(--rodio-teal), var(--rodio-teal-dk));
        color: #fff;
        font-size: 14px;
        font-weight: 800;
    }

    .rodio-mh__wordmark-accent {
        color: var(--rodio-teal);
    }

    .rodio-mh__actions {
        display: flex;
        align-items: center;
        gap: 2px;
    }

    /* Contador: sobreescribe .ov-contador-carrito de ov-carrito-lateral-ajax */
    .rodio-mh .rodio-mh__cart-count {
        position: absolute;
        top: 6px;
        right: 6px;
        bottom: auto;
        min-width: 16px;
        height: 16px;
        padding: 0 3px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        background: var(--rodio-teal);
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        line-height: 1;
        pointer-events: none;
    }

    .rodio-mh .rodio-mh__cart-count[data-count="0"] {
        display: none;
    }

    /* ── Búsqueda (botón que abre la pantalla Buscar) ────────────────────── */
    .rodio-mh__search {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0 16px 8px;
        padding: 0 14px;
        min-height: 44px;
        background: var(--rodio-surface);
        border: 1.5px solid transparent;
        border-radius: 12px;
        cursor: text;
    }

    .rodio-mh__search-icon,
    .rodio-msheet__search-icon {
        display: flex;
        flex-shrink: 0;
        color: var(--rodio-teal);
    }

    .rodio-mh__search-placeholder {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 14px;
        color: var(--rodio-gray-400);
    }

    /* ── Input real (pantalla Buscar) ─────────────────────────────────────── */
    .rodio-msheet__search {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0;
        padding: 0 14px;
        min-height: 46px;
        background: var(--rodio-surface);
        border: 1.5px solid var(--rodio-border);
        border-radius: 12px;
    }

    .rodio-msheet__search:focus-within {
        border-color: var(--rodio-teal);
    }

    .rodio-msheet__search input[type="search"] {
        flex: 1;
        min-width: 0;
        margin: 0;
        padding: 10px 0;
        background: transparent;
        border: 0;
        outline: 0;
        font-size: 16px; /* ≥16px evita el zoom automático de iOS */
        color: var(--rodio-ink);
        -webkit-appearance: none;
        appearance: none;
    }

    .rodio-msheet__search input[type="search"]::placeholder {
        color: var(--rodio-gray-400);
    }

    /* Cuando rt-algolia-search.js toma el input, su .aa-Form es la caja visible */
    .rodio-msheet__search:has(.rt-algolia-autocomplete-container) {
        padding: 0;
        background: none;
        border: 0;
    }

    .rodio-msheet__search:has(.rt-algolia-autocomplete-container) .rodio-msheet__search-icon {
        display: none;
    }

    .rodio-msheet__search .rt-algolia-autocomplete-container {
        width: 100%;
    }

    .rodio-msheet__search .rt-algolia-autocomplete-container .aa-Form {
        min-height: 46px;
        background: var(--rodio-surface);
        border: 1.5px solid var(--rodio-border);
        border-radius: 12px;
        box-shadow: none;
    }

    .rodio-msheet__search .rt-algolia-autocomplete-container .aa-Form:focus-within {
        border-color: var(--rodio-teal);
        box-shadow: none;
    }

    .rodio-msheet__search .rt-algolia-autocomplete-container .aa-Input {
        font-size: 16px;
        color: var(--rodio-ink);
    }

    .rodio-msheet__search .rt-algolia-autocomplete-container .aa-SubmitButton svg,
    .rodio-msheet__search .rt-algolia-autocomplete-container .aa-SearchIcon {
        color: var(--rodio-teal);
    }

    /* ── Enviar a ─────────────────────────────────────────────────────────── */
    .rodio-mh__ship {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 4px 16px 10px;
        font-size: 12px;
        line-height: 1.4;
        color: var(--rodio-gray-500);
    }

    .rodio-mh__ship strong {
        font-weight: 600;
        color: var(--rodio-ink);
    }

    .rodio-mh__ship-text {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .rodio-mh__ship-pin,
    .rodio-mh__ship-chevron {
        display: flex;
        flex-shrink: 0;
        color: var(--rodio-teal);
    }

    /* =========================================================================
     * DRAWER
     * ======================================================================= */
    .rodio-mdrawer-overlay {
        position: fixed;
        inset: 0;
        z-index: 100002;
        background: rgba(0, 0, 0, 0.5);
    }

    .rodio-mdrawer-overlay[hidden] {
        display: none;
    }

    .rodio-mdrawer {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 100003;
        width: 80%;
        max-width: 320px;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: #fff;
        color: var(--rodio-gray-700);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.3s;
    }

    .rodio-mdrawer.is-open {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
    }

    .rodio-mdrawer a {
        text-decoration: none;
    }

    .rodio-mdrawer__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 12px 12px 20px;
        border-bottom: 1px solid var(--rodio-border);
    }

    .rodio-mdrawer__head .rodio-mh__logo {
        flex: 0 1 auto;
        justify-content: flex-start;
    }

    .rodio-mdrawer__section {
        padding: 12px 20px 8px;
    }

    .rodio-mdrawer__title {
        margin: 0 0 8px;
        padding: 0;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 1px;
        text-transform: uppercase;
        color: var(--rodio-gray-400);
    }

    .rodio-mdrawer__list,
    .rodio-mdrawer__list ul {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .rodio-mdrawer__list a,
    .rodio-mdrawer__list summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        padding: 12px 4px;
        border-bottom: 1px solid var(--rodio-gray-100);
        font-size: 15px;
        font-weight: 500;
        line-height: 1.3;
        color: var(--rodio-gray-700);
        cursor: pointer;
    }

    .rodio-mdrawer__cats a,
    .rodio-mdrawer__cats summary {
        padding: 11px 4px;
        font-size: 14px;
    }

    .rodio-mdrawer__list summary {
        list-style: none;
    }

    .rodio-mdrawer__list summary::-webkit-details-marker {
        display: none;
    }

    .rodio-mdrawer__list .rodio-mh-icon {
        flex-shrink: 0;
        color: var(--rodio-gray-400);
        transition: transform 0.2s ease;
    }

    .rodio-mdrawer__list details[open] > summary .rodio-mh-icon {
        transform: rotate(90deg);
        color: var(--rodio-teal);
    }

    .rodio-mdrawer__list details ul {
        padding-left: 12px;
    }

    .rodio-mdrawer__list details ul a {
        font-size: 13px;
        color: var(--rodio-gray-600);
    }

    .rodio-mdrawer__list details ul a.rodio-mdrawer__all {
        font-weight: 600;
        color: var(--rodio-teal);
    }

    .rodio-mdrawer__list .current-menu-item > a {
        color: var(--rodio-teal);
    }

    html.rodio-mlock,
    html.rodio-mlock body {
        overflow: hidden;
    }

    /* =========================================================================
     * PANTALLAS COMPLETAS — Buscar / Categorías
     * top lo fija mobile-header.js (= borde inferior del header al abrir);
     * abajo dejan visible la barra inferior.
     * ======================================================================= */
    .rodio-msheet {
        position: fixed;
        top: var(--rodio-msheet-top, 0px);
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 9988;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--rodio-surface);
        color: var(--rodio-ink);
    }

    /* display:none cerrado → las miniaturas lazy no se descargan */
    .rodio-msheet[hidden] {
        display: none;
    }

    body.rodio-mbnav-active .rodio-msheet {
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    .rodio-msheet a {
        text-decoration: none;
    }

    .rodio-msheet__head {
        position: sticky;
        top: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        background: #fff;
        border-bottom: 1px solid var(--rodio-border);
    }

    .rodio-msheet__back {
        flex-shrink: 0;
        margin-left: -8px;
    }

    .rodio-msheet__title {
        margin: 0;
        padding: 0;
        font-size: 18px;
        font-weight: 800;
        line-height: 1.2;
        letter-spacing: -0.3px;
        color: var(--rodio-ink);
    }

    .rodio-msheet__subtitle {
        margin: 2px 0 0;
        padding: 0;
        font-size: 12px;
        line-height: 1.3;
        color: var(--rodio-gray-500);
    }

    .rodio-msheet__body {
        padding: 12px 16px 24px;
    }

    .rodio-msheet__body--cards {
        padding-top: 16px;
    }

    .rodio-msheet__label {
        margin: 20px 0 12px;
        padding: 0;
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        color: var(--rodio-gray-500);
    }

    .rodio-msheet__chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .rodio-msheet__chip {
        padding: 7px 14px;
        background: var(--rodio-surface);
        border: 1.5px solid var(--rodio-border);
        border-radius: 20px;
        font-size: 13px;
        font-weight: 500;
        line-height: 1.3;
        color: var(--rodio-gray-700);
    }

    .rodio-msheet__chip:active {
        border-color: var(--rodio-teal);
        color: var(--rodio-teal);
    }

    /* ── Tarjetas de categoría ────────────────────────────────────────────── */
    .rodio-mcats,
    .rodio-mcat__subs {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .rodio-mcats {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .rodio-mcat {
        overflow: hidden;
        background: #fff;
        border: 1.5px solid var(--rodio-border);
        border-radius: 14px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    }

    .rodio-mcat__row {
        display: flex;
        align-items: center;
        gap: 14px;
        width: 100%;
        padding: 14px 16px;
        cursor: pointer;
        list-style: none;
        -webkit-tap-highlight-color: transparent;
    }

    .rodio-mcat__row::-webkit-details-marker {
        display: none;
    }

    .rodio-mcat__thumb {
        width: 56px;
        height: 56px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        border-radius: 12px;
        background: var(--rodio-surface);
        color: var(--rodio-teal);
    }

    .rodio-msheet .rodio-mcat__img {
        width: 100%;
        height: 100%;
        max-width: none;
        object-fit: cover;
    }

    .rodio-mcat__text {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
    }

    .rodio-mcat__name {
        font-size: 15px;
        font-weight: 700;
        line-height: 1.3;
        color: var(--rodio-ink);
    }

    .rodio-mcat__count {
        margin-top: 3px;
        font-size: 12px;
        color: var(--rodio-gray-400);
    }

    .rodio-mcat__chevron {
        display: flex;
        flex-shrink: 0;
        color: var(--rodio-gray-400);
        transition: transform 0.2s ease;
    }

    .rodio-mcat details[open] .rodio-mcat__chevron {
        transform: rotate(90deg);
        color: var(--rodio-teal);
    }

    .rodio-mcat__subs {
        padding: 8px 16px 12px;
        border-top: 1px solid var(--rodio-gray-100);
    }

    .rodio-mcat__subs a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 10px 4px;
        border-bottom: 1px solid var(--rodio-gray-50);
        font-size: 14px;
        font-weight: 500;
        color: var(--rodio-gray-700);
    }

    .rodio-mcat__subs li:last-child a {
        border-bottom: 0;
    }

    .rodio-mcat__subs .rodio-mh-icon {
        flex-shrink: 0;
        color: var(--rodio-gray-400);
    }

    .rodio-mcat__subs a.rodio-mcat__all {
        font-weight: 600;
        color: var(--rodio-teal);
    }

    /* Pestaña de la pantalla abierta resaltada; la de la página actual se apaga */
    html.rodio-msheet-open .rodio-mbnav__item.is-active:not(.is-sheet-active) {
        color: var(--rodio-gray-400);
    }

    html.rodio-msheet-open .rodio-mbnav__item.is-active:not(.is-sheet-active) span {
        font-weight: 500;
    }

    .rodio-mbnav__item.is-sheet-active {
        color: var(--rodio-teal);
    }

    .rodio-mbnav__item.is-sheet-active span {
        font-weight: 700;
    }

    /* =========================================================================
     * BARRA INFERIOR
     * ======================================================================= */
    body.rodio-mbnav-active {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    .rodio-mbnav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 9989;
        display: flex;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #fff;
        border-top: 1px solid var(--rodio-border);
    }

    .rodio-mbnav__item {
        flex: 1;
        min-height: 56px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 9px 4px;
        background: none;
        border: 0;
        color: var(--rodio-gray-400);
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .rodio-mbnav__item span {
        margin-top: 3px;
        font-size: 10px;
        font-weight: 500;
        line-height: 1.2;
    }

    .rodio-mbnav__item.is-active {
        color: var(--rodio-teal);
    }

    .rodio-mbnav__item.is-active span {
        font-weight: 700;
    }

    /* Divi "volver arriba" no debe quedar tapado por la barra */
    body.rodio-mbnav-active .et_pb_scroll_top {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
}

/* Barra de admin de WP: el header sticky baja lo que mide la barra.
   ≤600px la barra es position:absolute y se va con el scroll → top 0. */
@media (min-width: 601px) and (max-width: 782px) {
    body.admin-bar .rodio-mh {
        top: 46px;
    }
}

@media (min-width: 783px) and (max-width: 980px) {
    body.admin-bar .rodio-mh {
        top: 32px;
    }
}

@media (max-width: 980px) and (prefers-reduced-motion: reduce) {
    .rodio-mdrawer,
    .rodio-mdrawer.is-open,
    .rodio-mdrawer__list .rodio-mh-icon {
        transition: none;
    }
}
