/* Shared compact layout: sticky bottom nav, footer clearance, drawer stacking. */
body.aps-mobile-redesign.aps-home-sticky-nav main {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

/*
 * Toast / alert chrome — keep below sticky compact header (z-index 60).
 * Covers #toast (layout), #parts-toast (listing/detail cart), SweetAlert2 toasts.
 * Use right:0 + inner padding so translate-x-full fully clears the viewport
 * (a right inset leaves a white sliver when "hidden").
 */
body.aps-mobile-redesign #toast,
body.aps-mobile-redesign #parts-toast {
    top: calc(4.75rem + env(safe-area-inset-top, 0px)) !important;
    right: 0 !important;
    left: auto !important;
    z-index: 70 !important;
    max-width: calc(100vw - 0.75rem);
    padding-right: 0.75rem;
    box-sizing: border-box;
}

/* Fully hide when slid off-screen (no edge peek) */
body.aps-mobile-redesign #toast.translate-x-full,
body.aps-mobile-redesign #parts-toast.translate-x-full {
    visibility: hidden !important;
    pointer-events: none !important;
}

body.aps-mobile-redesign #toast:not(.translate-x-full),
body.aps-mobile-redesign #parts-toast:not(.translate-x-full) {
    visibility: visible !important;
    pointer-events: auto !important;
}

body.aps-mobile-redesign .swal2-container.swal2-top,
body.aps-mobile-redesign .swal2-container.swal2-top-end,
body.aps-mobile-redesign .swal2-container.swal2-top-start {
    top: calc(4.75rem + env(safe-area-inset-top, 0px)) !important;
    z-index: 70 !important;
}

/*
 * Iubenda privacy chrome — fixed bottom-right on compact redesign.
 * IMPORTANT: do NOT target [class*="iubenda-uspr"] / [id*="iubenda-uspr"].
 * Those match nested USPR children; forcing them all to position:fixed stacks
 * every glyph at the same point (garbled "Your Privacy Choices" on Samsung).
 * Only style the top-level controls (links / buttons / prefs FAB).
 */
body.aps-mobile-redesign a.iubenda-cs-preferences-link,
body.aps-mobile-redesign button.iubenda-cs-preferences-link,
body.aps-mobile-redesign a.iubenda-cs-uspr-link,
body.aps-mobile-redesign button.iubenda-cs-uspr-link,
body.aps-mobile-redesign #iubenda-cs-banner.iubenda-cs-default-floating,
body.aps-mobile-redesign .iubenda-tp-btn,
body.aps-mobile-redesign #iubenda-cs-banner:not(.iubenda-cs-visible) {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    z-index: 54 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    margin: 0 !important;
    transform: none !important;
}

/* Cookie prefs keyhole — bottom-right */
body.aps-mobile-redesign a.iubenda-cs-preferences-link,
body.aps-mobile-redesign button.iubenda-cs-preferences-link,
body.aps-mobile-redesign .iubenda-tp-btn,
body.aps-mobile-redesign #iubenda-cs-banner.iubenda-cs-default-floating,
body.aps-mobile-redesign #iubenda-cs-banner:not(.iubenda-cs-visible) {
    right: 0.55rem !important;
}

/*
 * US "Your Privacy Choices" — icon-only next to the keyhole.
 * Samsung (and some WebViews) still garble the label text; keep the CCPA
 * icon so the control stays usable without the distracting mash of letters.
 * Also target div-based USPR widgets (not only a/button.iubenda-cs-uspr-link).
 */
body.aps-mobile-redesign a.iubenda-cs-uspr-link,
body.aps-mobile-redesign button.iubenda-cs-uspr-link,
body.aps-mobile-redesign [class*="iubenda-uspr-btn"],
body.aps-mobile-redesign [id^="iubenda-uspr"]:not([id^="iubenda-uspr"] *) {
    right: 3.35rem !important;
    width: 2.5rem !important;
    max-width: 2.5rem !important;
    height: 2.5rem !important;
    padding: 0.2rem !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    letter-spacing: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

/* Nested USPR bits must stay in normal flow (never fixed) or glyphs stack. */
body.aps-mobile-redesign a.iubenda-cs-uspr-link *,
body.aps-mobile-redesign button.iubenda-cs-uspr-link *,
body.aps-mobile-redesign [class*="iubenda-uspr"] *,
body.aps-mobile-redesign [id*="iubenda-uspr"] * {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    float: none !important;
}

/* Hide label / letter nodes; keep the official CCPA icon (img/svg). */
body.aps-mobile-redesign a.iubenda-cs-uspr-link span,
body.aps-mobile-redesign button.iubenda-cs-uspr-link span,
body.aps-mobile-redesign a.iubenda-cs-uspr-link [class*="caption"],
body.aps-mobile-redesign button.iubenda-cs-uspr-link [class*="caption"],
body.aps-mobile-redesign a.iubenda-cs-uspr-link [class*="label"],
body.aps-mobile-redesign button.iubenda-cs-uspr-link [class*="label"],
body.aps-mobile-redesign a.iubenda-cs-uspr-link [class*="text"],
body.aps-mobile-redesign button.iubenda-cs-uspr-link [class*="text"],
body.aps-mobile-redesign [class*="iubenda-uspr"] span,
body.aps-mobile-redesign [class*="iubenda-uspr"] [class*="caption"],
body.aps-mobile-redesign [class*="iubenda-uspr"] [class*="label"],
body.aps-mobile-redesign [class*="iubenda-uspr"] [class*="text"],
body.aps-mobile-redesign [id*="iubenda-uspr"] span {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    font-size: 0 !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    clip: rect(0, 0, 0, 0) !important;
}

body.aps-mobile-redesign a.iubenda-cs-uspr-link img,
body.aps-mobile-redesign button.iubenda-cs-uspr-link img,
body.aps-mobile-redesign a.iubenda-cs-uspr-link svg,
body.aps-mobile-redesign button.iubenda-cs-uspr-link svg,
body.aps-mobile-redesign [class*="iubenda-uspr"] img,
body.aps-mobile-redesign [class*="iubenda-uspr"] svg,
body.aps-mobile-redesign [id*="iubenda-uspr"] img,
body.aps-mobile-redesign [id*="iubenda-uspr"] svg {
    display: block !important;
    width: 1.65rem !important;
    height: 1.65rem !important;
    max-width: 100% !important;
    max-height: 100% !important;
    font-size: initial !important;
    line-height: normal !important;
    color: initial !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    clip: auto !important;
}

body.aps-mobile-redesign.aps-home-sticky-nav.aps-bottom-nav-visible a.iubenda-cs-preferences-link,
body.aps-mobile-redesign.aps-home-sticky-nav.aps-bottom-nav-visible button.iubenda-cs-preferences-link,
body.aps-mobile-redesign.aps-home-sticky-nav.aps-bottom-nav-visible a.iubenda-cs-uspr-link,
body.aps-mobile-redesign.aps-home-sticky-nav.aps-bottom-nav-visible button.iubenda-cs-uspr-link,
body.aps-mobile-redesign.aps-home-sticky-nav.aps-bottom-nav-visible #iubenda-cs-banner.iubenda-cs-default-floating,
body.aps-mobile-redesign.aps-home-sticky-nav.aps-bottom-nav-visible .iubenda-tp-btn,
body.aps-mobile-redesign.aps-home-sticky-nav.aps-bottom-nav-visible #iubenda-cs-banner:not(.iubenda-cs-visible) {
    bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px)) !important;
}

body.aps-mobile-redesign.aps-home-sticky-nav:not(.aps-bottom-nav-visible) a.iubenda-cs-preferences-link,
body.aps-mobile-redesign.aps-home-sticky-nav:not(.aps-bottom-nav-visible) button.iubenda-cs-preferences-link,
body.aps-mobile-redesign.aps-home-sticky-nav:not(.aps-bottom-nav-visible) a.iubenda-cs-uspr-link,
body.aps-mobile-redesign.aps-home-sticky-nav:not(.aps-bottom-nav-visible) button.iubenda-cs-uspr-link,
body.aps-mobile-redesign.aps-home-sticky-nav:not(.aps-bottom-nav-visible) #iubenda-cs-banner.iubenda-cs-default-floating,
body.aps-mobile-redesign.aps-home-sticky-nav:not(.aps-bottom-nav-visible) .iubenda-tp-btn,
body.aps-mobile-redesign.aps-home-sticky-nav:not(.aps-bottom-nav-visible) #iubenda-cs-banner:not(.iubenda-cs-visible),
body.aps-mobile-redesign:not(.aps-home-sticky-nav) a.iubenda-cs-preferences-link,
body.aps-mobile-redesign:not(.aps-home-sticky-nav) button.iubenda-cs-preferences-link,
body.aps-mobile-redesign:not(.aps-home-sticky-nav) a.iubenda-cs-uspr-link,
body.aps-mobile-redesign:not(.aps-home-sticky-nav) button.iubenda-cs-uspr-link,
body.aps-mobile-redesign:not(.aps-home-sticky-nav) #iubenda-cs-banner.iubenda-cs-default-floating,
body.aps-mobile-redesign:not(.aps-home-sticky-nav) .iubenda-tp-btn,
body.aps-mobile-redesign:not(.aps-home-sticky-nav) #iubenda-cs-banner:not(.iubenda-cs-visible) {
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important;
}

/* Expanded cookie consent banner — fixed to bottom, clears sticky nav. */
body.aps-mobile-redesign #iubenda-cs-banner.iubenda-cs-visible {
    position: fixed !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    z-index: 70 !important;
    margin: 0 !important;
    transform: none !important;
}

body.aps-mobile-redesign.aps-home-sticky-nav.aps-bottom-nav-visible #iubenda-cs-banner.iubenda-cs-visible {
    bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px)) !important;
}

body.aps-mobile-redesign.aps-home-sticky-nav:not(.aps-bottom-nav-visible) #iubenda-cs-banner.iubenda-cs-visible,
body.aps-mobile-redesign:not(.aps-home-sticky-nav) #iubenda-cs-banner.iubenda-cs-visible {
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important;
}

body.aps-mobile-redesign.homepage {
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

body.aps-mobile-redesign.homepage main {
    flex: 1 0 auto;
    position: relative;
    z-index: 2;
    order: 2;
    min-height: 0 !important;
    padding-bottom: 0;
}

body.aps-mobile-redesign.homepage .aps-homepage-footer-wrap {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    order: 3;
    margin-bottom: 0;
}

.aps-mobile-bottom-nav {
    position: fixed;
    left: 50%;
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 55;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.2rem;
    width: calc(100% - 1.1rem);
    max-width: 24rem;
    padding: 0.65rem 0.75rem 0.5rem;
    background: #002d2f;
    border-radius: 9999px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
    transition: transform 0.24s ease, opacity 0.24s ease, visibility 0.24s ease;
}

.aps-mobile-bottom-nav.aps-mobile-bottom-nav--hidden {
    transform: translateX(-50%) translateY(calc(100% + 2rem));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body.aps-mobile-redesign #modal-overlay,
body.aps-mobile-redesign #ms-freetext-overlay.is-open {
    z-index: 70 !important;
}

body.aps-mobile-redesign #mobile-menu-overlay,
body.aps-mobile-redesign #location-drawer-overlay,
body.aps-mobile-redesign #cart-drawer-overlay,
body.aps-mobile-redesign #mobile-recent-searches-overlay {
    z-index: 70 !important;
    inset: 0 !important;
}

body.aps-mobile-redesign #mobile-menu-drawer,
body.aps-mobile-redesign #location-drawer,
body.aps-mobile-redesign #cart-drawer {
    top: 0 !important;
    height: 100% !important;
    max-height: 100dvh;
}

/* Recent searches bottom sheet (compact sticky nav) */
.aps-mobile-recent-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    /* Keep page from stealing swipes; drawer body re-enables pan-y */
    touch-action: none;
    overscroll-behavior: none;
}

.aps-mobile-recent-drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.aps-mobile-recent-drawer {
    width: 100%;
    max-width: 28rem;
    /* Bound height so the body becomes the scrollport (real iOS/Android) */
    max-height: min(78dvh, 78vh, 36rem);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 1.25rem 1.25rem 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.22);
    transform: translateY(100%);
    transition: transform 0.28s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow: hidden;
    touch-action: pan-y;
}

.aps-mobile-recent-drawer.is-open {
    transform: translateY(0);
}

.aps-mobile-recent-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.1rem 0.85rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.aps-mobile-recent-drawer__title {
    margin: 0;
    font-family: 'Wix Madefor Display', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #002d2f;
}

.aps-mobile-recent-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 9999px;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    font-size: 1rem;
}

.aps-mobile-recent-drawer__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 0.85rem 1rem 0.5rem;
}

.aps-mobile-recent-drawer__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 0;
    color: #6b7280;
    font-size: 0.9rem;
}

.aps-mobile-recent-drawer__list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.aps-mobile-recent-drawer__empty {
    margin: 0;
    padding: 2rem 0.5rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.95rem;
}

.aps-mobile-recent-drawer__footer {
    flex-shrink: 0;
    padding: 0.65rem 1rem 1rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.aps-mobile-recent-drawer__view-all {
    display: inline-block;
    font-family: 'Wix Madefor Display', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #00786a;
    text-decoration: none;
}

.aps-mobile-recent-drawer__view-all:hover {
    text-decoration: underline;
}

.recent-search-row--mobile-drawer {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 2.75rem 0.75rem 0.85rem;
    margin-bottom: 0;
    background: #f3f4f6;
    border-radius: 0.85rem;
    color: #002d2f;
    cursor: pointer;
    transition: background 0.2s ease;
}

.recent-search-row--mobile-drawer:active {
    background: #e5e7eb;
}

.recent-search-row--mobile-drawer .recent-search-row__icon {
    flex-shrink: 0;
    width: 2rem;
    color: #00a88a;
    text-align: center;
    font-size: 0.95rem;
}

.recent-search-row--mobile-drawer .recent-search-row__body {
    flex: 1 1 auto;
    min-width: 0;
}

.recent-search-row--mobile-drawer .recent-search-row__title {
    font-family: 'Wix Madefor Display', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.recent-search-row--mobile-drawer .recent-search-row__subtitle {
    margin-top: 0.15rem;
    font-size: 0.78rem;
    line-height: 1.3;
    color: #4b5563;
}

.recent-search-row--mobile-drawer .recent-search-row__vin {
    font-weight: 500;
    color: #4b5563;
}

.recent-search-row--mobile-drawer .remove-search-btn {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.85rem;
}

.recent-search-row--mobile-drawer .remove-search-btn:hover,
.recent-search-row--mobile-drawer .remove-search-btn:active {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.aps-mobile-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.28rem;
    flex: 1 1 0;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
}

.aps-mobile-bottom-nav__item.is-active .aps-mobile-bottom-nav__label {
    color: #00ffb7;
}

.aps-mobile-bottom-nav__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.45rem;
    height: 2.45rem;
    border-radius: 9999px;
    background: #00FFB5;
    color: #002d2f;
    font-size: 0.95rem;
    position: relative;
}

.aps-mobile-bottom-nav__icon--cart {
    overflow: visible;
}

.aps-mobile-bottom-nav__badge {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    width: 1rem;
    height: 1rem;
    min-width: 1rem;
    padding: 0;
    border-radius: 9999px;
    background: #00FFB5;
    color: #002D2F;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
    box-sizing: border-box;
    box-shadow: 0 0 0 2px rgba(0, 45, 47, 0.1);
}

.aps-mobile-bottom-nav__label {
    font-family: 'Wix Madefor Display', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
    color: #fff;
}
