/* =========================================================================
   CITYMOTOR - MOBILE HEADER V3
   Compact two-row redesign for mobile (≤767px).
   - Row 1: dark masthead with centered logo, left MENU control, right cart
   - Row 2: always-visible search bar below thin red divider
   Desktop (≥768px) is NOT modified.
   Load after cm-header-v1.css.
   ========================================================================= */

/* Row 2 container — hidden on desktop by default */
.cm-mobile-search-row {
    display: none;
}

/* ===== MOBILE ONLY (≤767px) ===== */
@media (max-width: 767px) {

    /* ---- Reset box-sizing for our injected row ---- */
    .cm-mobile-search-row,
    .cm-mobile-search-row *,
    .cm-mobile-search-row *::before,
    .cm-mobile-search-row *::after {
        box-sizing: border-box;
    }

    /* ---- Compact masthead ---- */
    #masthead {
        padding: 0;
        border-bottom: none !important;
        box-shadow: none !important;
    }
    #masthead::after {
        display: none !important;
    }

    /* ---- Hide existing mobile search icon (search moves to row 2) ---- */
    body.ast-header-break-point #masthead .ast-header-search,
    body.ast-header-break-point #masthead .ast-search-menu-icon {
        display: none !important;
    }

    /* ---- Menu toggle: dark rounded button, thin red border, hamburger + MENÚ ---- */
    body.ast-header-break-point #masthead .menu-toggle.main-header-menu-toggle {
        background: #121212 !important;
        border: 1px solid rgba(255, 16, 32, 0.55) !important;
        border-radius: 999px !important;
        box-shadow: none !important;
        color: #ffffff !important;
        padding: 6px 14px !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        min-height: 34px !important;
    }
    body.ast-header-break-point #masthead .menu-toggle.main-header-menu-toggle::after {
        content: "MENÚ" !important;
        margin-left: 0 !important;
        color: #ffffff !important;
        font-size: 11px !important;
        font-weight: 900 !important;
        line-height: 1 !important;
    }
    body.ast-header-break-point #masthead .menu-toggle.main-header-menu-toggle svg,
    body.ast-header-break-point #masthead .menu-toggle.main-header-menu-toggle svg path,
    body.ast-header-break-point #masthead .menu-toggle.main-header-menu-toggle .ast-icon,
    body.ast-header-break-point #masthead .menu-toggle.main-header-menu-toggle .ast-icon path {
        fill: #ffffff !important;
        color: #ffffff !important;
    }

    /* ---- Cart icon: dark rounded button, white icon, red badge ---- */
    body.ast-header-break-point #masthead .ast-site-header-cart .ast-addon-cart-wrap {
        background: #121212 !important;
        border: 1px solid rgba(255, 255, 255, 0.18) !important;
        border-radius: 999px !important;
        color: #ffffff !important;
        width: 38px !important;
        height: 38px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    body.ast-header-break-point #masthead .ast-site-header-cart .ast-addon-cart-wrap svg,
    body.ast-header-break-point #masthead .ast-site-header-cart .ast-addon-cart-wrap svg path,
    body.ast-header-break-point #masthead .ast-site-header-cart .ast-addon-cart-wrap .ast-icon,
    body.ast-header-break-point #masthead .ast-site-header-cart .ast-addon-cart-wrap .ast-icon path {
        fill: #ffffff !important;
        color: #ffffff !important;
    }
    body.ast-header-break-point #masthead .ast-site-header-cart .count,
    body.ast-header-break-point #masthead .ast-site-header-cart .ast-cart-count {
        background: #ff1020 !important;
        color: #ffffff !important;
        border: 2px solid #121212 !important;
        font-weight: 900 !important;
        top: -6px !important;
        right: -6px !important;
        min-width: 18px !important;
        height: 18px !important;
        font-size: 10px !important;
        line-height: 14px !important;
        border-radius: 999px !important;
    }

    /* ---- Left/Right section widths for balanced layout ---- */
    body.ast-header-break-point #masthead .site-header-primary-section-left {
        flex: 0 0 auto !important;
        min-width: 80px;
        justify-content: flex-start !important;
    }
    body.ast-header-break-point #masthead .site-header-primary-section-right {
        flex: 0 0 auto !important;
        min-width: 80px;
        justify-content: flex-end !important;
        gap: 6px !important;
    }

    /* ---- Logo: centered, compact ---- */
    body.ast-header-break-point #masthead img.custom-logo {
        width: clamp(58px, 15vw, 70px) !important;
        max-height: 64px !important;
    }
    #masthead .custom-logo-link {
        margin: 0 !important;
        filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.12));
    }
    #masthead .ast-builder-layout-element[data-section="title_tagline"] {
        margin: 0 !important;
    }
    body.ast-header-break-point #masthead .site-header-primary-section-center {
        justify-content: center !important;
    }

    /* ---- Row 2: persistent search bar ---- */
    .cm-mobile-search-row {
        display: block !important;
        width: 100%;
        background: #0a0a0a;
        padding: 8px 12px 10px;
        border-top: 1px solid #ff1020;
        position: relative;
        z-index: 40;
    }
    .cm-mobile-search-row .search-form {
        display: flex;
        align-items: center;
        background: #1a1a1a;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 8px;
        overflow: hidden;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
    }
    .cm-mobile-search-row .search-field {
        flex: 1 1 auto;
        min-height: 42px;
        background: transparent !important;
        border: none !important;
        color: #ffffff !important;
        font-size: 14px;
        padding: 0 12px;
        outline: none;
        width: 100%;
        box-shadow: none !important;
    }
    .cm-mobile-search-row .search-field::placeholder {
        color: rgba(255, 255, 255, 0.7) !important;
        opacity: 1 !important;
        font-weight: 400 !important;
    }
    .cm-mobile-search-row .search-submit {
        flex: 0 0 auto;
        background: transparent !important;
        border: none !important;
        color: #ffffff !important;
        padding: 0 14px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 42px;
        border-radius: 0 !important;
    }
    .cm-mobile-search-row .search-submit svg,
    .cm-mobile-search-row .search-submit .ast-icon {
        fill: #ffffff !important;
        color: #ffffff !important;
        width: 20px;
        height: 20px;
    }

    /* ---- Override V1 fixed slide-search overlay (mobile) ---- */
    body.ast-header-break-point #masthead .ast-search-menu-icon.slide-search .search-form {
        display: none !important;
    }

    /* ---- Ensure no horizontal overflow ---- */
    body.ast-header-break-point #masthead .ast-container,
    body.ast-header-break-point #masthead .site-primary-header-wrap {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 12px !important;
    }
    #page {
        overflow-x: hidden;
    }

    /* ---- Hide empty grid column spacers that cause overflow ---- */
    body.ast-header-break-point #masthead .ast-builder-grid-row > .site-header-section:empty {
        display: none;
    }
}


/* ========================================================================
   OTACON QA FIX — mobile Astra header has no center column.
   Recompose the existing mobile elements into the reference layout.
   ======================================================================== */
@media (max-width: 767px) {
    #ast-mobile-header {
        background: linear-gradient(180deg, #080808 0%, #111111 100%) !important;
        overflow: visible !important;
    }

    #ast-mobile-header .ast-primary-header-bar {
        min-height: 96px !important;
        padding: 0 12px !important;
    }

    #ast-mobile-header .ast-builder-grid-row {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        min-height: 96px !important;
    }

    #ast-mobile-header .site-header-primary-section-left {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        min-width: 0 !important;
        height: 96px !important;
    }

    #ast-mobile-header .site-header-primary-section-right {
        display: none !important;
    }

    #ast-mobile-header .ast-builder-layout-element[data-section="title_tagline"] {
        position: absolute !important;
        top: 7px !important;
        left: 50% !important;
        width: auto !important;
        margin: 0 !important;
        transform: translateX(-50%) !important;
        z-index: 2 !important;
    }

    #ast-mobile-header img.custom-logo {
        display: block !important;
        width: 82px !important;
        height: 82px !important;
        max-width: none !important;
        max-height: none !important;
        object-fit: contain !important;
    }

    #ast-mobile-header .ast-builder-layout-element[data-section="section-header-mobile-trigger"] {
        position: absolute !important;
        top: 26px !important;
        left: 0 !important;
        margin: 0 !important;
        z-index: 4 !important;
    }

    #ast-mobile-header .menu-toggle.main-header-menu-toggle {
        min-width: 98px !important;
        min-height: 44px !important;
        padding: 6px 14px !important;
        justify-content: center !important;
    }

    #ast-mobile-header .ast-builder-layout-element.ast-header-woo-cart {
        display: block !important;
        position: absolute !important;
        top: 29px !important;
        right: 0 !important;
        margin: 0 !important;
        z-index: 4 !important;
    }

    #ast-mobile-header .ast-site-header-cart,
    #ast-mobile-header .ast-site-header-cart-li,
    #ast-mobile-header .cart-container {
        display: block !important;
        width: auto !important;
        height: auto !important;
    }

    #ast-mobile-header .ast-site-header-cart .ast-addon-cart-wrap {
        width: 38px !important;
        height: 38px !important;
    }

    #ast-mobile-header .ast-header-account,
    #ast-mobile-header .ast-header-search {
        display: none !important;
    }
}


@media (max-width: 767px) {
    body.ast-header-break-point #ast-mobile-header img.custom-logo {
        width: 82px !important;
        height: 82px !important;
        max-width: none !important;
        max-height: none !important;
    }

    #ast-mobile-header .ast-builder-layout-element[data-section="section-header-mobile-trigger"] {
        left: -10px !important;
    }
}


@media (max-width: 767px) {
    #ast-mobile-header .ast-builder-layout-element[data-section="title_tagline"],
    #ast-mobile-header .site-branding,
    #ast-mobile-header .custom-logo-link {
        height: 82px !important;
        min-height: 82px !important;
    }

    #ast-mobile-header .custom-logo-link {
        align-items: flex-start !important;
    }
}


@media (max-width: 767px) {
    #ast-mobile-header .custom-logo-link {
        position: relative !important;
        display: block !important;
        width: 82px !important;
        height: 82px !important;
    }

    #ast-mobile-header img.custom-logo {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 82px !important;
        height: 82px !important;
    }
}


@media (max-width: 767px) {
    #ast-mobile-header .ast-builder-layout-element[data-section="title_tagline"] {
        width: 82px !important;
        padding: 0 !important;
    }

    #ast-mobile-header .site-branding {
        padding: 0 !important;
    }
}


/* === Menú mobile: rojo neón === */
@media (max-width: 767px) {
    #ast-mobile-header .menu-toggle.main-header-menu-toggle {
        background: #ff1020 !important;
        border-color: #ff1020 !important;
        color: #ffffff !important;
        box-shadow: 0 0 12px rgba(255, 16, 32, 0.62), 0 6px 18px rgba(255, 16, 32, 0.28) !important;
    }

    #ast-mobile-header .menu-toggle.main-header-menu-toggle:hover,
    #ast-mobile-header .menu-toggle.main-header-menu-toggle:focus-visible {
        background: #ff2635 !important;
        border-color: #ff2635 !important;
        box-shadow: 0 0 16px rgba(255, 38, 53, 0.78), 0 8px 22px rgba(255, 16, 32, 0.34) !important;
    }
}


/* === Especificidad final contra Astra V1 === */
@media (max-width: 767px) {
    body.ast-header-break-point #ast-mobile-header .menu-toggle.main-header-menu-toggle {
        background: #ff1020 !important;
        border-color: #ff1020 !important;
        color: #ffffff !important;
        box-shadow: 0 0 12px rgba(255, 16, 32, 0.62), 0 6px 18px rgba(255, 16, 32, 0.28) !important;
    }

    body.ast-header-break-point #ast-mobile-header .menu-toggle.main-header-menu-toggle:hover,
    body.ast-header-break-point #ast-mobile-header .menu-toggle.main-header-menu-toggle:focus-visible {
        background: #ff2635 !important;
        border-color: #ff2635 !important;
        box-shadow: 0 0 16px rgba(255, 38, 53, 0.78), 0 8px 22px rgba(255, 16, 32, 0.34) !important;
    }
}


/* === Production compatibility: compensate Astra offset on mobile === */
@media (max-width: 767px) {
    #masthead {
        margin-top: 24px !important;
    }
}
