/*
 * Cloudflare-style compact shell.
 *
 * The desktop sidebar remains the canonical navigation renderer. At the shared
 * mobile breakpoint this layer presents that same element as an off-canvas
 * drawer and retires the legacy fixed bottom tab rail.
 */

.ff-mobile-menu-trigger,
.ff-mobile-menu-head,
.ff-mobile-menu-backdrop {
    display: none;
}

.ff-site-sidebar--mobile-only {
    display: none !important;
}

@media (max-width: 900px) {
    :root {
        --ff-mobile-drawer-width: min(86vw, 320px);
        --ff-mobile-shell-control: 44px;
    }

    body.ff-mobile-menu-open {
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.ff-mobile-menu-open .header,
    body.ff-mobile-menu-open .ff-site-header,
    body.ff-mobile-menu-open .vf-mobile-toolbar {
        z-index: 0 !important;
    }

    .ff-mobile-menu-trigger {
        display: inline-flex;
        width: var(--ff-mobile-shell-control);
        min-width: var(--ff-mobile-shell-control);
        height: var(--ff-mobile-shell-control);
        min-height: var(--ff-mobile-shell-control);
        align-items: center;
        justify-content: center;
        padding: 0;
        border: 0;
        border-radius: 6px;
        background: transparent;
        color: #fff;
        box-shadow: none;
        cursor: pointer;
        touch-action: manipulation;
    }

    .ff-mobile-menu-trigger:hover,
    .ff-mobile-menu-trigger:focus-visible,
    .ff-mobile-menu-trigger[aria-expanded="true"] {
        background: rgba(255, 255, 255, 0.13);
        color: #fff;
        outline: none;
    }

    .ff-mobile-menu-trigger:focus-visible {
        box-shadow: 0 0 0 3px rgba(125, 184, 255, 0.42);
    }

    .ff-mobile-menu-trigger svg,
    .ff-mobile-menu-close svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    /* Shared header: compact identity row, then route-owned search. */
    .ff-site-header .ff-site-header-row {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) var(--ff-mobile-shell-control) !important;
        grid-template-areas:
            "lead actions"
            "center center";
        align-items: center;
        gap: 8px !important;
        min-height: 0;
        padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 9px !important;
    }

    .ff-site-header .ff-site-lead {
        grid-area: lead;
        display: flex !important;
        width: auto !important;
        min-width: 0;
        min-height: var(--ff-mobile-shell-control);
        align-items: center;
        justify-content: flex-start !important;
        gap: 6px;
        padding: 0 !important;
    }

    .ff-site-header .ff-site-home {
        width: auto !important;
        min-width: 0;
        min-height: var(--ff-mobile-shell-control);
        justify-content: flex-start !important;
        color: #fff;
        font-size: 17px;
        font-weight: 700;
    }

    .ff-site-header .ff-site-logo {
        height: 20px;
        filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
    }

    .ff-site-header .ff-site-count {
        display: none !important;
    }

    .ff-site-header .ff-site-center {
        grid-area: center;
        width: 100%;
        min-width: 0;
    }

    body:has(.ff-site-search-placeholder) .ff-site-header .ff-site-center {
        display: none !important;
    }

    /* Inventory bridge follows the same shell without duplicating its search. */
    .header.ff-site-header-bridge .header-row {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) var(--ff-mobile-shell-control) !important;
        grid-template-areas:
            "lead actions"
            "center center";
        align-items: center;
        gap: 8px !important;
        min-height: 0;
        padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 9px !important;
    }

    .header.ff-site-header-bridge .header-lead,
    body:has(#main-content.homepage-main) .header.ff-site-header-bridge .header-lead {
        grid-area: lead;
        display: flex !important;
        width: auto !important;
        min-width: 0;
        min-height: var(--ff-mobile-shell-control);
        flex-direction: row;
        align-items: center;
        justify-content: flex-start !important;
        gap: 6px;
        padding: 0 !important;
    }

    .header.ff-site-header-bridge .header-brand-row,
    body:has(#main-content.homepage-main) .header.ff-site-header-bridge .header-brand-row,
    .header.ff-site-header-bridge .home-button,
    body:has(#main-content.homepage-main) .header.ff-site-header-bridge .home-button {
        width: auto !important;
        min-width: 0;
        justify-content: flex-start !important;
    }

    .header.ff-site-header-bridge .home-button {
        min-height: var(--ff-mobile-shell-control);
        color: #fff;
        font-size: 17px;
        font-weight: 700;
    }

    .header.ff-site-header-bridge .home-counts,
    .header.ff-site-header-bridge .header-subtitle {
        display: none !important;
    }

    .header.ff-site-header-bridge .header-center {
        grid-area: center;
        width: 100%;
        min-width: 0;
        order: initial;
    }

    /* Retire the fixed rail; keep the existing Account control in the top row. */
    .ff-site-header .ff-site-actions,
    .header.ff-site-header-bridge .header-right,
    body:has(.main:not(.homepage-main)) .header.ff-site-header-bridge .header-right:not(.hidden) {
        grid-area: actions;
        position: static !important;
        inset: auto !important;
        z-index: auto;
        display: flex !important;
        width: var(--ff-mobile-shell-control) !important;
        max-width: var(--ff-mobile-shell-control) !important;
        height: var(--ff-mobile-shell-control) !important;
        min-height: var(--ff-mobile-shell-control) !important;
        align-items: center;
        justify-content: center;
        gap: 0;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        transform: none !important;
        overflow: visible;
        isolation: auto;
        visibility: visible;
        pointer-events: auto;
    }

    .ff-site-header .ff-site-actions::before,
    .header.ff-site-header-bridge .header-right::before {
        content: none !important;
        display: none !important;
    }

    .ff-site-header .ff-site-actions > *,
    .header.ff-site-header-bridge .header-right > * {
        display: none !important;
    }

    .ff-site-header .ff-site-actions > .ff-site-tab-crm,
    .ff-site-header .ff-site-actions > .ff-site-tab-new,
    .ff-site-header .ff-site-actions > .ff-site-tab-used,
    .header.ff-site-header-bridge .header-right > #crm-button,
    .header.ff-site-header-bridge .header-right > #mobile-tab-new,
    .header.ff-site-header-bridge .header-right > #mobile-tab-used {
        display: none !important;
    }

    .ff-site-header .ff-site-actions > .ff-site-tab-profile,
    .header.ff-site-header-bridge .header-right > .profile-button-wrap {
        position: static !important;
        display: flex !important;
        width: var(--ff-mobile-shell-control) !important;
        height: var(--ff-mobile-shell-control) !important;
        min-height: var(--ff-mobile-shell-control) !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    .ff-site-header .ff-site-actions .ff-site-tab-profile .profile-button,
    .header.ff-site-header-bridge .header-right #profile-button {
        display: inline-flex !important;
        width: var(--ff-mobile-shell-control) !important;
        min-width: var(--ff-mobile-shell-control) !important;
        height: var(--ff-mobile-shell-control) !important;
        min-height: var(--ff-mobile-shell-control) !important;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 6px !important;
        background: transparent !important;
        color: #fff !important;
        box-shadow: none !important;
        transform: none !important;
    }

    .ff-site-header .ff-site-actions .profile-button:hover,
    .ff-site-header .ff-site-actions .profile-button:focus-visible,
    .header.ff-site-header-bridge .header-right #profile-button:hover,
    .header.ff-site-header-bridge .header-right #profile-button:focus-visible {
        background: rgba(255, 255, 255, 0.13) !important;
        outline: none;
    }

    .ff-site-header .ff-site-actions .profile-button svg,
    .header.ff-site-header-bridge .header-right #profile-button svg {
        display: block !important;
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.9;
    }

    .ff-site-header .ff-site-actions .profile-button.is-authed svg,
    .header.ff-site-header-bridge .header-right #profile-button.is-authed svg {
        display: none !important;
    }

    .ff-site-header .ff-site-actions .profile-button.is-authed .avatar-initials,
    .header.ff-site-header-bridge .header-right #profile-button.is-authed .avatar-initials {
        display: inline-flex !important;
        color: #fff;
        font-size: 12px;
        font-weight: 750;
    }

    .ff-site-header .ff-site-actions .ff-site-action-mobile-label,
    .ff-site-header .ff-site-actions .ff-site-action-mobile-icon,
    .ff-site-header .ff-site-actions .ff-site-profile-desktop-icon,
    .header.ff-site-header-bridge .header-right .mobile-tab-label {
        display: none !important;
    }

    .ff-site-header .ff-site-actions .account-menu,
    .header.ff-site-header-bridge .header-right .account-menu {
        display: none !important;
    }

    .page,
    body:has(.ff-site-header) {
        padding-bottom: 0 !important;
    }

    .main.homepage-main {
        padding-bottom: 18px !important;
    }

    .vf-page {
        padding-bottom: 18px !important;
    }

    .vf-mobile-toolbar {
        grid-template-columns: var(--ff-mobile-shell-control) auto 1fr var(--ff-mobile-shell-control) var(--ff-mobile-shell-control) !important;
    }

    .vf-mobile-toolbar .ff-mobile-menu-trigger {
        color: #172033;
    }

    .vf-mobile-toolbar .ff-mobile-menu-trigger:hover,
    .vf-mobile-toolbar .ff-mobile-menu-trigger:focus-visible,
    .vf-mobile-toolbar .ff-mobile-menu-trigger[aria-expanded="true"] {
        background: #e8ebef;
        color: #172033;
    }

    .crm-modal {
        bottom: 0 !important;
    }

    .status-list-overlay,
    #vehicle-map-overlay,
    #feedback-overlay,
    .ford-doc-chooser-overlay {
        bottom: 0 !important;
    }

    /* The canonical desktop navigation becomes the mobile drawer. */
    .ff-site-sidebar[data-site-navigation] {
        position: fixed !important;
        inset: 0 auto 0 0 !important;
        z-index: 10050 !important;
        display: flex !important;
        width: var(--ff-mobile-drawer-width) !important;
        max-width: var(--ff-mobile-drawer-width) !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        min-height: 100vh;
        flex-direction: column;
        align-self: auto;
        padding: 0 !important;
        border: 0 !important;
        border-right: 1px solid var(--ff-site-border, #d9e0ea) !important;
        border-radius: 0 !important;
        background: #f8f9fb !important;
        box-shadow: 18px 0 42px rgba(15, 23, 42, 0.22) !important;
        color: var(--ff-site-fg, #1d1d1f);
        font-family: var(--ff-font-sans);
        overflow: hidden;
        visibility: hidden;
        pointer-events: none;
        opacity: 0;
        transform: translate3d(-100%, 0, 0);
        transition:
            transform 180ms cubic-bezier(0.2, 0, 0, 1),
            opacity 150ms ease,
            visibility 0s linear 180ms;
    }

    .ff-site-sidebar[data-site-navigation].is-mobile-menu-open {
        visibility: visible;
        pointer-events: auto;
        opacity: 1;
        transform: translate3d(0, 0, 0);
        transition:
            transform 220ms cubic-bezier(0.2, 0, 0, 1),
            opacity 160ms ease,
            visibility 0s linear 0s;
    }

    .ff-mobile-menu-head {
        display: flex;
        min-height: calc(62px + env(safe-area-inset-top, 0px));
        flex: 0 0 auto;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: calc(9px + env(safe-area-inset-top, 0px)) 12px 9px 20px;
        border-bottom: 1px solid var(--ff-site-border, #d9e0ea);
        background: #fff;
    }

    .ff-mobile-menu-brand {
        display: inline-flex;
        min-width: 0;
        min-height: var(--ff-mobile-shell-control);
        align-items: center;
        gap: 8px;
        color: var(--ff-site-fg, #1d1d1f);
        font-size: 16px;
        font-weight: 700;
        line-height: 1.2;
        text-decoration: none;
    }

    .ff-mobile-menu-brand img {
        display: block;
        width: auto;
        height: 21px;
    }

    .ff-mobile-menu-close {
        display: inline-flex;
        width: var(--ff-mobile-shell-control);
        min-width: var(--ff-mobile-shell-control);
        height: var(--ff-mobile-shell-control);
        align-items: center;
        justify-content: center;
        padding: 0;
        border: 0;
        border-radius: 6px;
        background: transparent;
        color: #4f5968;
        box-shadow: none;
        cursor: pointer;
        touch-action: manipulation;
    }

    .ff-mobile-menu-close:hover,
    .ff-mobile-menu-close:focus-visible {
        background: #e8ebef;
        color: #1d1d1f;
        outline: none;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav {
        display: flex;
        flex: 1 1 auto;
        min-width: 0;
        min-height: 0;
        flex-direction: column;
        gap: 18px;
        padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px));
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-group {
        display: grid;
        gap: 3px;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-group-secondary {
        margin-top: auto;
        padding-top: 12px;
        border-top: 1px solid var(--ff-site-border, #d9e0ea);
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-label {
        padding: 0 10px 7px;
        color: var(--ff-site-muted, #667085);
        font-size: 11px;
        font-weight: 650;
        letter-spacing: 0.05em;
        line-height: 1.2;
        text-transform: uppercase;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-item {
        display: flex;
        width: 100%;
        min-width: 0;
        min-height: 46px;
        align-items: center;
        gap: 11px;
        padding: 10px;
        border: 0;
        border-radius: 4px;
        background: transparent;
        color: var(--ff-site-fg, #1d1d1f);
        font-size: 15px;
        font-weight: 500;
        line-height: 1.2;
        text-decoration: none;
        touch-action: manipulation;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-item--mobile-only {
        display: flex !important;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-item[hidden] {
        display: none !important;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-item:hover,
    .ff-site-sidebar[data-site-navigation] .workspace-nav-item:focus-visible {
        background: #eef0f3;
        color: var(--ff-site-fg, #1d1d1f);
        outline: none;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-item:focus-visible {
        box-shadow: var(--ff-site-focus-ring, 0 0 0 4px rgba(0, 113, 227, 0.18));
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-item.is-active {
        background: #e3e7ec;
        color: var(--ff-site-fg, #1d1d1f);
        font-weight: 650;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-icon {
        display: inline-flex;
        width: 20px;
        height: 20px;
        flex: 0 0 20px;
        align-items: center;
        justify-content: center;
        color: #66707d;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-icon svg {
        width: 19px;
        height: 19px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-icon .ff-nav-glyph {
        fill: currentColor;
        stroke: none;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-icon .ff-nav-glyph-fill {
        display: none;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-item.is-active .ff-nav-glyph-regular {
        display: none;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-item.is-active .ff-nav-glyph-fill {
        display: block;
    }

    .ff-site-sidebar[data-site-navigation] .workspace-nav-short-label {
        margin-left: 5px;
        padding: 1px 5px;
        border-radius: 3px;
        background: rgba(0, 0, 0, 0.055);
        color: var(--ff-site-muted, #667085);
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        vertical-align: 1px;
    }

    .ff-mobile-menu-backdrop:not([hidden]) {
        position: fixed;
        inset: 0;
        z-index: 10040;
        display: block;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: rgba(15, 23, 42, 0.48);
        cursor: default;
        -webkit-tap-highlight-color: transparent;
    }

    @media (prefers-reduced-motion: reduce) {
        .ff-site-sidebar[data-site-navigation] {
            transition: none;
        }
    }
}
