/* APW header pass40: restore 1440 shell + keep topbar right + prevent vehicle/search overlap */

@media (min-width: 1024px) {
  :root {
    --apw-shell-max: 1440px;
    --apw-shell-side: max(16px, calc((100vw - var(--apw-shell-max)) / 2));
  }

  /* Keep main site content from stretching past 1440 on desktop/ultra-wide. */
  .site__body {
    max-width: var(--apw-shell-max) !important;
    width: 100%;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Catch legacy pages that render directly under .site instead of .site__body. */
  .site > .container,
  .site > .container-fluid,
  .site > .container-fullwidth,
  .site > .container-padding,
  .site > .row-fluid {
    max-width: var(--apw-shell-max) !important;
    width: 100%;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Header shell */
  .site__header .header {
    position: relative;
    z-index: 10;
    background: transparent !important;
    box-shadow: none !important;
    grid-template-rows: 34px auto auto;
    grid-template-columns:
      var(--apw-shell-side)
      minmax(240px, 310px)
      minmax(0, 1fr)
      max-content
      var(--apw-shell-side) !important;
  }

  .site__header .header__topbar-classic,
  .site__header .header__logo,
  .site__header .header__search,
  .site__header .header__indicators {
    position: relative;
    z-index: 1;
  }

  .site__header .header__topbar-classic { grid-column: 2 / 5 !important; }
  .site__header .header__logo { grid-column: 2 !important; min-width: 0 !important; margin-right: 18px !important; background: transparent !important; border: 0 !important; box-shadow: none !important; }
  .site__header .header__search { grid-column: 3 !important; min-width: 0 !important; margin-right: 18px !important; background: transparent !important; border: 0 !important; box-shadow: none !important; }
  .site__header .header__indicators { grid-column: 4 !important; padding: 16px 0 16px 10px !important; background: transparent !important; border: 0 !important; box-shadow: none !important; white-space: nowrap; }

  /* White center strip only, not full-width white row. */
  .site__header .header::before {
    content: '';
    position: absolute;
    left: var(--apw-shell-side);
    right: var(--apw-shell-side);
    top: 34px;
    height: 58px;
    background: #fff;
    box-shadow: none !important;
    border: 0 !important;
    z-index: 0;
  }

  /* Dark top bar and red nav stay full bleed. */
  .site__header .header__topbar-classic-bg,
  .site__header .header__navbar {
    width: 100vw !important;
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
  }

  .site__header .header__topbar-classic-bg {
    background: #333 !important;
  }

  .site__header .header__navbar {
    padding-left: var(--apw-shell-side) !important;
    padding-right: var(--apw-shell-side) !important;
  }

  /* Top bar alignment: left text on left, links/flags on right. */
  .topbar--classic {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
  }
  .topbar--classic .topbar__item-text,
  .topbar--classic .topbar__item-button,
  .topbar--classic .topbar__menu.flag-top {
    flex: 0 0 auto !important;
  }
  .topbar--classic .topbar__item-spring {
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 12px !important;
  }

  /* Search / vehicle row sizing */
  .site__header .header__search .search,
  .site__header .header__search .search__body {
    width: 100% !important;
    min-width: 0 !important;
  }
  .site__header .header__search .search__body {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }
  .site__header .header__search .clsright {
    float: none !important;
    flex: 0 1 240px !important;
    min-width: 190px !important;
    max-width: 240px !important;
    margin: 0 !important;
  }
  .site__header .header__search .clsleft {
    float: none !important;
    flex: 1 1 auto !important;
    min-width: 260px !important;
  }
  .site__header .header__search .clsleft > div {
    position: relative !important;
    width: 100% !important;
  }
  .site__header .header__search #search_desktop_form {
    float: none !important;
    width: 100% !important;
  }
  .site__header .header__search #search_desktop {
    float: none !important;
    width: 100% !important;
    max-width: none !important;
  }

  .apw-header-vehicle-button {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }
  .apw-header-vehicle-button__label {
    min-width: 0 !important;
    max-width: none !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}

/* Mid desktop: keep shell stable and free up space for search so the pill never overlaps it. */
@media (min-width: 1024px) and (max-width: 1339.98px) {
  .site__header .header {
    grid-template-columns: 16px minmax(210px, 280px) minmax(0, 1fr) max-content 16px !important;
  }
  .site__header .header::before {
    left: 16px;
    right: 16px;
  }
  .site__header .header__navbar {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .site__header .header__logo .logo__image img.apwcalogo {
    width: 255px !important;
    height: auto !important;
  }
  .site__header .header__search .clsright {
    flex-basis: 205px !important;
    min-width: 175px !important;
    max-width: 205px !important;
  }
  .site__header .header__search .clsleft {
    min-width: 210px !important;
  }
  .site__header .header__indicators .indicator__title,
  .site__header .header__indicators .indicator__value {
    display: none !important;
  }
}

/* Wider desktop: bring back a bit more room for the pill and labels. */
@media (min-width: 1340px) {
  .site__header .header__logo .logo__image img.apwcalogo {
    width: 270px !important;
    height: auto !important;
  }
  .site__header .header__search .clsright {
    flex-basis: 250px !important;
    min-width: 200px !important;
    max-width: 250px !important;
  }
}

/* pass41: make footer consistent on all page shells.
   Keep footer inner content capped at 1440, but paint the dark footer bands full-bleed. */
@media (min-width: 1024px) {
  .site__footer,
  .site-footer,
  .site-footer__widgets,
  .site-footer__bottom {
    position: relative !important;
    overflow: visible !important;
  }

  /* Keep actual content rows inside the same centered shell. */
  .site-footer__widgets > .container,
  .site-footer__bottom > .container {
    width: 100% !important;
    max-width: var(--apw-shell-max) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    position: relative !important;
    z-index: 1 !important;
  }

  /* Remove element-width dependency for the dark backgrounds. */
  .site-footer__widgets,
  .site-footer__bottom {
    background: transparent !important;
  }

  .site-footer__widgets::before,
  .site-footer__bottom::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 100vw;
    transform: translateX(-50%);
    z-index: 0;
    pointer-events: none;
  }

  .site-footer__widgets::before {
    background: #333 !important;
  }

  .site-footer__bottom::before {
    background: #2b2b2b !important;
  }

  /* Keep footer blocks centered even on legacy pages that widened the footer internals. */
  .site-footer__widgets .row,
  .site-footer__bottom-row {
    width: 100% !important;
  }
}

/* pass43: force footer shell consistency across mixed page layouts.
   Break the footer itself out to full viewport width, then cap only the inner content. */
@media (min-width: 1024px) {
  .site__footer,
  .site__footer .site-footer,
  footer.site__footer,
  footer.site__footer .site-footer {
    position: relative !important;
    left: 50% !important;
    right: auto !important;
    width: 100vw !important;
    max-width: none !important;
    margin-left: -50vw !important;
    margin-right: 0 !important;
    transform: none !important;
    overflow: visible !important;
    background: #333 !important;
  }

  .site__footer .site-footer__widgets,
  .site__footer .site-footer__bottom {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }

  .site__footer .site-footer__widgets > .container,
  .site__footer .site-footer__bottom > .container,
  .site__footer .site-footer__widgets > .container-fluid,
  .site__footer .site-footer__bottom > .container-fluid {
    width: min(var(--apw-shell-max), calc(100vw - 32px)) !important;
    max-width: var(--apw-shell-max) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    position: relative !important;
    z-index: 2 !important;
  }

  .site__footer .site-footer__widgets::before,
  .site__footer .site-footer__bottom::before {
    left: 50vw !important;
    width: 100vw !important;
    transform: translateX(-50%) !important;
  }
}


/* pass45: remove stray header separator lines around the logo row without touching layout. */
@media (min-width: 1024px) {
  .site__header .header,
  .site__header .header::before,
  .site__header .header__logo,
  .site__header .header__search,
  .site__header .header__indicators,
  .site__header .header__logo .logo,
  .site__header .header__logo .logo__image,
  .site__header .header__logo .logo__image img,
  .site__header .header__logo a {
    border-top: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
  }

  .site__header .header::after,
  .site__header .header__logo::before,
  .site__header .header__logo::after,
  .site__header .header__search::before,
  .site__header .header__search::after,
  .site__header .header__indicators::before,
  .site__header .header__indicators::after,
  .site__header .header__logo .logo::before,
  .site__header .header__logo .logo::after,
  .site__header .header__logo a::before,
  .site__header .header__logo a::after {
    display: none !important;
    content: none !important;
  }
}
