/* ═══════════════════════════════════════════════
   AUTOFLIPER — Floating Pill Header
   v2.0.0
═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ─── RESET MOTORS HEADER ─── */
.stm-header-main,
.stm_header_top,
.stm-header,
header.site-header,
#masthead,
[class*="stm-header"],
.main-navigation,
.stm_header_wrapper,
.stm-header-layout {
    display: none !important;
}

/* ─── BODY OFFSET ─── */
body {
    padding-top: 80px !important;
    margin-top: 0 !important;
}

@media (max-width: 768px) {
    body {
        padding-top: 0px !important;
        padding-bottom: 80px !important;
    }
}

/* ═══════════════════════════════════════════════
   DESKTOP HEADER — Floating Pill
═══════════════════════════════════════════════ */
#af-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9990;
    padding: 14px 24px;
    transition: all 0.35s ease;
    font-family: 'DM Sans', -apple-system, sans-serif;
    pointer-events: none;
}

.af-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255,255,255,0.0);
    border: 1px solid rgba(0,0,0,0.0);
    border-radius: 100px;
    padding: 0 20px;
    transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
    pointer-events: all;
}

/* Scrolled state — pill appears */
#af-header.scrolled .af-header-inner {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 4px 32px rgba(0,0,0,0.10);
}

/* At top — full transparent bar */
#af-header:not(.scrolled) .af-header-inner {
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}

/* LOGO */
.af-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 24px;
}

.af-logo img {
    height: 34px;
    width: auto;
    transition: all 0.3s;
}

/* NAV LINKS */
.af-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.af-nav a {
    font-size: 14px;
    font-weight: 500;
    color: #2a2a2a;
    text-decoration: none;
    padding: 6px 13px;
    border-radius: 100px;
    transition: all 0.15s;
    white-space: nowrap;
}

.af-nav a:hover {
    color: #B32726;
    background: rgba(179,39,38,0.08);
}

.af-nav a.active {
    color: #B32726;
    font-weight: 600;
    background: rgba(179,39,38,0.06);
}

/* RIGHT ACTIONS */
.af-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.af-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2a2a2a;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    font-size: 16px;
    font-family: 'DM Sans', sans-serif;
}

.af-icon-btn:hover {
    background: rgba(0,0,0,0.06);
    color: #B32726;
}

.af-icon-btn svg {
    width: 18px;
    height: 18px;
}

/* AI button */
.af-ai-btn {
    width: 36px;
    height: 36px;
    border-radius: 100px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2a2a2a;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 16px;
    position: relative;
    overflow: visible;
}

.af-ai-btn:hover {
    background: rgba(0,0,0,0.06);
    color: #B32726;
}

.af-ai-btn svg { width: 18px; height: 18px; }

/* Hide Google Translate's own widget/banner — we use the custom language switcher */
#google_translate_element,
.goog-te-gadget,
.goog-te-gadget-icon,
.goog-te-banner-frame,
#goog-te-banner-frame,
.goog-te-banner-frame.skiptranslate,
.goog-logo-link { display: none !important; }
.goog-text-highlight { background: none !important; box-shadow: none !important; }
body { top: 0 !important; }

.af-ai-pulse {
    display: none;
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid #B32726;
    animation: af-pulse 2.5s ease-out infinite;
    opacity: 0;
}

@keyframes af-pulse {
    0%   { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* Divider */
.af-divider {
    width: 1px;
    height: 20px;
    background: rgba(0,0,0,0.1);
    margin: 0 4px;
}

/* CTA button */
.af-cta-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 14px;
    height: 34px;
    background: #B32726;
    color: #fff;
    border-radius: 100px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    margin-left: 4px;
}

.af-cta-btn:hover {
    background: #8f1f1e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(179,39,38,0.3);
}

.af-cta-btn svg { width: 14px; height: 14px; }

/* Message badge */
.af-msg-badge {
    position: absolute;
    top: 2px; right: 2px;
    width: 14px; height: 14px;
    background: #B32726;
    color: #fff;
    border-radius: 50%;
    font-size: 8px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════════
   MOBILE TOP BAR
═══════════════════════════════════════════════ */
#af-mobile-top {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9990;
    background: #ffffff;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    padding: 10px 16px;
    align-items: center;
    justify-content: space-between;
    font-family: 'DM Sans', sans-serif;
    height: 56px;
    box-sizing: border-box;
}

.af-mobile-logo img {
    height: 30px;
    width: auto;
}

.af-mobile-icons {
    display: flex;
    align-items: center;
    gap: 2px;
}

.af-mobile-icon-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2a2a2a;
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    font-size: 16px;
    position: relative;
}

.af-mobile-icon-btn svg { width: 20px; height: 20px; }
.af-mobile-icon-btn:active { background: #f5f5f7; border-radius: 10px; }

.af-mobile-ai-btn {
    background: transparent !important;
    border-radius: 10px;
    color: #2a2a2a !important;
}

/* ═══════════════════════════════════════════════
   MOBILE BOTTOM NAV
═══════════════════════════════════════════════ */
#af-mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 9990;
    background: rgba(255,255,255,0.97);
    border-top: 1px solid rgba(0,0,0,0.08);
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
    font-family: 'DM Sans', sans-serif;
}

.af-mobile-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px;
}

.af-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 8px;
    border-radius: 14px;
    text-decoration: none;
    color: #9999a8;
    transition: all 0.2s;
    min-width: 52px;
    height: 46px;
    border: none;
    background: none;
    cursor: pointer;
    margin: 0;
    line-height: 1;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    font-family: 'DM Sans', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.af-nav-item svg { display: block; }

.af-nav-item svg { width: 22px; height: 22px; stroke: currentColor; }
.af-nav-item span { font-size: 10px; font-weight: 600; line-height: 1; }
.af-nav-item.active, .af-nav-item:active { color: #B32726; }

/* Center ADD button */
.af-nav-add {
    width: 52px; height: 52px;
    background: #B32726;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    gap: 2px;
    box-shadow: 0 4px 16px rgba(179,39,38,0.4);
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    margin-top: -14px;
}

.af-nav-add svg { width: 20px; height: 20px; }
.af-nav-add span { font-size: 9px; font-weight: 700; }
.af-nav-add:active { transform: scale(0.95); }

/* ═══════════════════════════════════════════════
   SLIDE-IN MENU
═══════════════════════════════════════════════ */
#af-mobile-menu {
    position: fixed;
    top: 0; right: -320px;
    width: 300px; height: 100%;
    background: #fff;
    z-index: 99999;
    transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
    font-family: 'DM Sans', sans-serif;
    box-shadow: -8px 0 40px rgba(0,0,0,0.12);
}

#af-mobile-menu.open { right: 0; }

#af-menu-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99998;
    display: none;
}
#af-menu-overlay.open { display: block; }

.af-menu-header {
    padding: 18px 18px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f5;
}

.af-menu-header img { height: 28px; }

.af-menu-close {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: #f5f5f7;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2a2a2a;
}

.af-menu-links {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.af-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: #1d1d1f;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.15s;
}

.af-menu-link svg { width: 20px; height: 20px; flex-shrink: 0; color: #6e6e73; }
.af-menu-link:hover, .af-menu-link.active { background: rgba(179,39,38,0.07); color: #B32726; }
.af-menu-link:hover svg, .af-menu-link.active svg { color: #B32726; }

.af-menu-divider {
    height: 1px;
    background: #f0f0f5;
    margin: 6px 10px;
}

.af-menu-cta {
    margin: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: #B32726;
    color: #fff;
    border-radius: 14px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
    transition: all 0.15s;
}
.af-menu-cta:hover { background: #8f1f1e; }

/* ═══════════════════════════════════════════════
   RESPONSIVE SHOW/HIDE
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    #af-header { display: none !important; }
    #af-mobile-top { display: flex !important; }
    #af-mobile-nav { display: block !important; }
    #afai-widget-btn { display: none !important; }
    #afai-chat-window {
        bottom: 84px !important;
        right: 10px !important;
        width: calc(100vw - 20px) !important;
    }
}

@media (min-width: 769px) {
    #af-header { display: block !important; }
    #af-mobile-top { display: none !important; }
    #af-mobile-nav { display: none !important; }
}

/* ═══════════════════════════════════════════════
   LANGUAGE SWITCHER — Integrated in Header
═══════════════════════════════════════════════ */
.af-lang-wrap {
    position: relative;
}

.af-lang-pop {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    overflow: hidden;
    min-width: 100px;
    z-index: 99999;
    animation: af-dropdown-in 0.18s ease;
}

.af-lang-pop.open { display: block; }

@keyframes af-dropdown-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.af-lang-pop button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    color: #1d1d1f;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    text-align: left;
    transition: background 0.1s;
    white-space: nowrap;
}

.af-lang-pop button:last-child { border-bottom: none; }
.af-lang-pop button:hover { background: rgba(179,39,38,0.07); color: #B32726; }

/* Mobile lang dropdown */
.af-lang-pop-m {
    top: calc(100% + 8px);
    right: 0;
    min-width: 60px;
}

.af-lang-pop-m button {
    padding: 10px;
    font-size: 18px;
    justify-content: center;
}

/* ═══════════════════════════════════════════════
   MOBILE BOTTOM NAV — Pill Style
═══════════════════════════════════════════════ */
#af-mobile-nav {
    padding: 10px 16px max(14px, env(safe-area-inset-bottom));
    background: transparent;
    border-top: none;
}

.af-mobile-pill {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 100px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    padding: 8px 12px;
}

.af-nav-item {
    padding: 6px 12px;
    border-radius: 100px;
    min-width: auto;
}

.af-nav-item.active {
    background: rgba(179,39,38,0.08);
}

.af-nav-item svg { width: 20px; height: 20px; }
.af-nav-item span { font-size: 10px; }

.af-nav-add {
    width: 48px;
    height: 48px;
    border-radius: 100px;
    margin-top: -6px;
    box-shadow: 0 4px 16px rgba(179,39,38,0.4);
}

/* ═══════════════════════════════════════════════
   AI CHAT WINDOW — Fix position & font
═══════════════════════════════════════════════ */
#afai-chat-window {
    font-size: 15px !important;
}

#afai-messages {
    font-size: 15px !important;
}

.afai-bubble {
    font-size: 15px !important;
    line-height: 1.55 !important;
}

@media (max-width: 768px) {
    #afai-chat-window {
        bottom: 100px !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
    }
}

/* Hide old fixed lang switcher if present */
#af-lang-switcher {
    display: none !important;
}

/* ═══════════════════════════════════════════════
   ICON COLOR LOCK (v3.8)
   Some pages (e.g. /add-car/) load Motors form CSS that recolors
   buttons/links red. These high-specificity !important rules keep
   the header icons monochrome everywhere. CTA & Sell stay red.
═══════════════════════════════════════════════ */
#af-header .af-icon-btn,
#af-header .af-ai-btn,
#af-mobile-top .af-mobile-icon-btn {
    background: transparent !important;
    color: #2a2a2a !important;
    box-shadow: none !important;
}
#af-header .af-icon-btn:hover,
#af-header .af-ai-btn:hover {
    background: rgba(0,0,0,0.06) !important;
    color: #B32726 !important;
}
#af-header .af-icon-btn svg,
#af-header .af-ai-btn svg,
#af-mobile-top .af-mobile-icon-btn svg {
    stroke: currentColor !important;
    fill: none !important;
}
#af-mobile-nav .af-nav-item {
    color: #9999a8 !important;
    background: transparent !important;
}
#af-mobile-nav .af-nav-item.active {
    color: #B32726 !important;
}
#af-mobile-nav .af-nav-item svg {
    stroke: currentColor !important;
    fill: none !important;
}

/* ═══════════════════════════════════════════════
   FULL STYLE LOCK (v3.9)
   Isolates the header from theme/form CSS (e.g. /add-car/ which
   recolors every button/link). Re-asserts intended styles with
   high specificity + !important. CTA + Sell stay red on purpose.
═══════════════════════════════════════════════ */

/* Desktop nav links */
#af-header .af-nav a {
    color: #2a2a2a !important;
    background: transparent !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    text-decoration: none !important;
    box-shadow: none !important;
}
#af-header .af-nav a:hover,
#af-header .af-nav a.active {
    color: #B32726 !important;
    background: rgba(179,39,38,0.08) !important;
}

/* Icon buttons */
#af-header .af-icon-btn,
#af-header .af-ai-btn,
#af-mobile-top .af-mobile-icon-btn {
    background: transparent !important;
    color: #2a2a2a !important;
    box-shadow: none !important;
    text-transform: none !important;
}
#af-header .af-icon-btn:hover,
#af-header .af-ai-btn:hover {
    background: rgba(0,0,0,0.06) !important;
    color: #B32726 !important;
}
#af-header .af-icon-btn svg,
#af-header .af-ai-btn svg,
#af-mobile-top .af-mobile-icon-btn svg {
    stroke: currentColor !important;
    fill: none !important;
}

/* Language dropdown — clean white popup, not a red column */
#af-header .af-lang-pop,
#af-mobile-top .af-lang-pop {
    background: #ffffff !important;
}
#af-header .af-lang-pop button,
#af-mobile-top .af-lang-pop button {
    background: transparent !important;
    color: #1d1d1f !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    box-shadow: none !important;
    width: 100% !important;
    min-height: 0 !important;
}
#af-mobile-top .af-lang-pop-m button {
    font-size: 18px !important;
    justify-content: center !important;
}
#af-header .af-lang-pop button:hover,
#af-mobile-top .af-lang-pop button:hover {
    background: rgba(179,39,38,0.07) !important;
    color: #B32726 !important;
}

/* CTA "Add your car" — red with white visible text */
#af-header .af-cta-btn {
    background: #B32726 !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}
#af-header .af-cta-btn:hover { background: #8f1f1e !important; }
#af-header .af-cta-btn svg { stroke: #ffffff !important; fill: none !important; }

/* Bottom nav — small lowercase labels (no giant "MORE") */
#af-mobile-nav .af-nav-item {
    color: #9999a8 !important;
    background: transparent !important;
    box-shadow: none !important;
}
#af-mobile-nav .af-nav-item.active { color: #B32726 !important; }
#af-mobile-nav .af-nav-item span {
    font-size: 10px !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1 !important;
}
#af-mobile-nav .af-nav-item svg { stroke: currentColor !important; fill: none !important; }

/* Sell center button — red with visible white + and label */
#af-mobile-nav .af-nav-add {
    background: #B32726 !important;
    color: #ffffff !important;
}
#af-mobile-nav .af-nav-add span {
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}
#af-mobile-nav .af-nav-add svg { stroke: #ffffff !important; fill: none !important; }

/* Slide-in menu links (when you tap More) */
#af-mobile-menu .af-menu-link {
    color: #1d1d1f !important;
    background: transparent !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}
#af-mobile-menu .af-menu-link:hover,
#af-mobile-menu .af-menu-link.active {
    background: rgba(179,39,38,0.07) !important;
    color: #B32726 !important;
}
#af-mobile-menu .af-menu-link svg { stroke: currentColor !important; fill: none !important; }

/* ═══════════════════════════════════════════════
   ALIGNMENT + COMPONENT LOCK (v4.0)
   Forces buttons and anchors to identical boxes so icons line up,
   and fixes the menu close (×) and menu CTA.
═══════════════════════════════════════════════ */

/* Desktop action icons — identical 36x36 box, perfectly centered */
#af-header .af-header-actions { align-items: center !important; }
#af-header .af-icon-btn,
#af-header .af-ai-btn {
    width: 36px !important;
    height: 36px !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    align-self: center !important;
    border: none !important;
}
#af-header .af-icon-btn svg,
#af-header .af-ai-btn svg {
    width: 19px !important;
    height: 19px !important;
    display: block !important;
}

/* Mobile top icons — identical 36x36 box */
#af-mobile-top .af-mobile-icons { align-items: center !important; }
#af-mobile-top .af-mobile-icon-btn {
    width: 36px !important;
    height: 36px !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    border: none !important;
}
#af-mobile-top .af-mobile-icon-btn svg {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
}

/* Bottom nav — More (button) identical to the others (anchors) */
#af-mobile-nav .af-nav-item {
    height: 46px !important;
    min-height: 0 !important;
    padding: 6px 12px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    border: none !important;
}
#af-mobile-nav .af-nav-item svg {
    width: 22px !important;
    height: 22px !important;
    display: block !important;
}

/* Slide-in menu close (×) — clean centered circle, never red */
#af-mobile-menu .af-menu-close {
    background: #f0f0f2 !important;
    color: #1d1d1f !important;
    border: none !important;
    box-shadow: none !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    cursor: pointer !important;
    transition: background .15s, color .15s !important;
}
#af-mobile-menu .af-menu-close:hover {
    background: #e5e5ea !important;
    color: #B32726 !important;
}
#af-mobile-menu .af-menu-close svg {
    stroke: currentColor !important;
    fill: none !important;
    width: 16px !important;
    height: 16px !important;
    display: block !important;
}

/* Slide-in menu CTA — red with white visible text */
#af-mobile-menu .af-menu-cta {
    background: #B32726 !important;
    color: #ffffff !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}
#af-mobile-menu .af-menu-cta svg { stroke: #ffffff !important; fill: none !important; }
