/* =========================================================
   AutoMart Global Header + Sticky Search Stack V18.1
   Fix: preserve the main premium header and stack the search
   directly beneath it as one two-level sticky header system.
   ========================================================= */

:root{
  --am-main-header-h:72px;
  --am-green:#0b9153;
  --am-green-dark:#067744;
  --am-ink:#101828;
  --am-muted:#68758a;
  --am-line:#e2e9e5;
}

/* =========================================================
   LEVEL 1 — EXISTING MAIN HEADER
   Never hide, collapse, translate or place search over it.
   ========================================================= */
html body > header.premium-topbar,
html body header.premium-topbar[data-premium-header]{
  display:block!important;
  visibility:visible!important;
  opacity:1!important;
  position:sticky!important;
  top:0!important;
  z-index:1300!important;
  width:100%!important;
  margin:0!important;
  transform:none!important;
  translate:none!important;
  background:rgba(255,255,255,.985)!important;
  border-bottom:1px solid #edf1ef!important;
  box-shadow:none!important;
  backdrop-filter:blur(16px) saturate(135%)!important;
  -webkit-backdrop-filter:blur(16px) saturate(135%)!important;
}

/* Preserve the approved V8 nav shell instead of redesigning it. */
html body header.premium-topbar .premium-nav-shell{
  position:relative!important;
  z-index:1!important;
}

/* =========================================================
   LEVEL 2 — GLOBAL VEHICLE SEARCH
   Directly attached to the main header.
   ========================================================= */
html body .am-global-search-v18{
  position:sticky!important;
  top:var(--am-main-header-h)!important;
  z-index:1290!important;
  width:100%!important;
  margin:0!important;
  padding:0 18px 9px!important;
  background:rgba(255,255,255,.985)!important;
  border-top:0!important;
  border-bottom:1px solid rgba(221,229,225,.92)!important;
  box-shadow:0 11px 24px rgba(19,44,33,.055)!important;
  backdrop-filter:blur(16px) saturate(140%)!important;
  -webkit-backdrop-filter:blur(16px) saturate(140%)!important;
}

/* No floating gap between header and search. */
html body header.premium-topbar + .am-global-search-v18{
  margin-top:0!important;
}

/* Keep the search visually "flat" with the main header. */
html body .am-global-search-shell-v18{
  width:min(1780px,calc(100% - 18px))!important;
  margin:0 auto!important;
  padding:5px!important;
  border:1px solid #e2e9e5!important;
  border-top-color:#edf2ef!important;
  border-radius:0 0 20px 20px!important;
  background:#fff!important;
  box-shadow:0 8px 22px rgba(18,43,32,.045)!important;
}

html body .am-global-search-form-v18{
  display:grid!important;
  grid-template-columns:minmax(290px,1.55fr) minmax(145px,.72fr) minmax(145px,.72fr) minmax(126px,.62fr) minmax(158px,.78fr) auto auto!important;
  align-items:stretch!important;
  min-height:56px!important;
}

html body .am-global-search-main-v18,
html body .am-global-filter-v18{
  position:relative!important;
  display:flex!important;
  align-items:center!important;
  min-width:0!important;
  border-right:1px solid #e8eeeb!important;
}

html body .am-global-search-main-v18{
  padding:0 18px 0 16px!important;
}

html body .am-global-search-icon-v18,
html body .am-global-filter-icon-v18,
html body .am-global-more-icon-v18{
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  flex:0 0 auto!important;
  color:#172033!important;
}

html body .am-global-search-icon-v18{
  width:34px!important;
  height:34px!important;
  margin-right:8px!important;
}

html body .am-global-search-icon-v18 svg,
html body .am-global-filter-icon-v18 svg,
html body .am-global-more-icon-v18 svg,
html body .am-global-submit-v18 svg,
html body .am-global-mobile-toggle-v18 svg{
  width:22px!important;
  height:22px!important;
  fill:none!important;
  stroke:currentColor!important;
  stroke-width:1.8!important;
  stroke-linecap:round!important;
  stroke-linejoin:round!important;
}

html body .am-global-search-main-v18 input{
  width:100%!important;
  height:50px!important;
  min-width:0!important;
  border:0!important;
  outline:0!important;
  background:transparent!important;
  color:var(--am-ink)!important;
  font:600 14px/1.2 "Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif!important;
}

html body .am-global-search-main-v18 input::placeholder{
  color:#8a96a8!important;
  font-weight:500!important;
}

html body .am-global-filter-v18{
  padding:0 12px!important;
  gap:7px!important;
}

html body .am-global-filter-icon-v18{
  width:27px!important;
  height:27px!important;
  color:#213044!important;
}

html body .am-global-filter-v18 label{
  display:block!important;
  flex:1 1 auto!important;
  min-width:0!important;
}

html body .am-global-filter-v18 select{
  width:100%!important;
  height:50px!important;
  min-width:0!important;
  border:0!important;
  outline:0!important;
  background:transparent!important;
  color:#202938!important;
  padding:0 24px 0 0!important;
  font:750 12.5px/1 "Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif!important;
  cursor:pointer!important;
}

html body .am-global-more-v18{
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  gap:8px!important;
  min-width:154px!important;
  margin:5px 8px 5px 10px!important;
  padding:0 15px!important;
  border:1px solid #dfe7e3!important;
  border-radius:999px!important;
  background:#fbfcfc!important;
  color:#1e2b3c!important;
  text-decoration:none!important;
  font-size:12px!important;
  font-weight:800!important;
  white-space:nowrap!important;
}

html body .am-global-more-v18 b{
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  width:24px!important;
  height:24px!important;
  border-radius:50%!important;
  background:#0f9a5a!important;
  color:#fff!important;
  font-size:12px!important;
}

html body .am-global-submit-v18{
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  gap:10px!important;
  min-width:128px!important;
  margin:5px!important;
  padding:0 20px!important;
  border:0!important;
  border-radius:999px!important;
  background:linear-gradient(135deg,#11a664,#07894e)!important;
  color:#fff!important;
  font:800 13px/1 "Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif!important;
  cursor:pointer!important;
  box-shadow:0 8px 18px rgba(12,143,81,.18)!important;
}

html body .am-global-mobile-toggle-v18{
  display:none!important;
}

/* Hide only the OLD simple search strip on /vehicles.
   Never target premium-topbar or global search. */
html body.site-page .market-searchbar{
  display:none!important;
}

/* Anchored filters must not disappear behind the 2-level sticky header. */
html body #vehicle-filters,
html body .premium-filter-v14-1{
  scroll-margin-top:calc(var(--am-main-header-h) + 90px)!important;
}

/* =========================================================
   TABLET
   ========================================================= */
@media(max-width:1260px){
  html body .am-global-search-form-v18{
    grid-template-columns:minmax(245px,1.4fr) repeat(4,minmax(120px,.7fr)) auto!important;
  }
  html body .am-global-more-v18{
    display:none!important;
  }
  html body .am-global-submit-v18{
    min-width:112px!important;
  }
}

/* =========================================================
   MOBILE
   Main header stays first; search stays directly beneath it.
   ========================================================= */
@media(max-width:900px){
  html body .am-global-search-v18{
    padding:0 8px 7px!important;
  }

  html body .am-global-search-shell-v18{
    width:100%!important;
    padding:4px!important;
    border-radius:0 0 16px 16px!important;
  }

  html body .am-global-search-form-v18{
    grid-template-columns:minmax(0,1fr) auto auto!important;
    min-height:50px!important;
  }

  html body .am-global-search-main-v18{
    grid-column:1!important;
    padding-left:9px!important;
  }

  html body .am-global-search-main-v18 input{
    height:44px!important;
    font-size:13px!important;
  }

  html body .am-global-search-icon-v18{
    width:27px!important;
    height:27px!important;
  }

  html body .am-global-submit-v18{
    grid-column:2!important;
    width:46px!important;
    min-width:46px!important;
    margin:3px!important;
    padding:0!important;
    border-radius:13px!important;
  }

  html body .am-global-submit-v18 span{
    display:none!important;
  }

  html body .am-global-mobile-toggle-v18{
    grid-column:3!important;
    display:inline-flex!important;
    align-items:center!important;
    justify-content:center!important;
    gap:5px!important;
    min-width:76px!important;
    margin:3px!important;
    padding:0 9px!important;
    border:1px solid #dfe7e3!important;
    border-radius:13px!important;
    background:#fff!important;
    color:#273447!important;
    font:750 11px/1 "Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif!important;
  }

  html body .am-global-filter-v18,
  html body .am-global-more-v18{
    display:none!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-search-form-v18{
    grid-template-columns:1fr 1fr!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-search-main-v18{
    grid-column:1/-1!important;
    border-right:0!important;
    border-bottom:1px solid #e8eeeb!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-filter-v18{
    display:flex!important;
    min-height:46px!important;
    border-right:0!important;
    border-top:1px solid #eef2ef!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-filter-v18:nth-of-type(2n){
    border-right:1px solid #e8eeeb!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-more-v18{
    display:flex!important;
    grid-column:1!important;
    min-width:0!important;
    margin:6px 4px!important;
    min-height:44px!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-submit-v18{
    grid-column:2!important;
    width:auto!important;
    min-height:44px!important;
    border-radius:999px!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-submit-v18 span{
    display:inline!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-mobile-toggle-v18{
    position:absolute!important;
    right:10px!important;
    top:10px!important;
    width:40px!important;
    min-width:40px!important;
    height:40px!important;
    padding:0!important;
    border-radius:12px!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-mobile-toggle-v18 span{
    display:none!important;
  }
}

@media(max-width:520px){
  html body .am-global-search-form-v18{
    grid-template-columns:minmax(0,1fr) 44px 66px!important;
  }

  html body .am-global-mobile-toggle-v18{
    min-width:62px!important;
    padding:0 6px!important;
  }

  html body .am-global-search-main-v18 input{
    font-size:12px!important;
  }

  html body .am-global-search-v18.is-mobile-open .am-global-filter-v18{
    grid-column:1/-1!important;
    border-right:0!important;
  }
}

/* =========================================================
   AutoMart V18.1.1 — global search cleanup
   ========================================================= */

/* These are accessibility labels, never visual labels */
.am-global-search-v18 .sr-only{
    display:none !important;
}

/* Never allow global search contents to overflow vertically */
.am-global-search-v18 .am-global-search-shell-v18,
.am-global-search-v18 .am-global-search-form-v18{
    overflow:hidden !important;
}

