/* ── Megamenu trigger button ── */
.has-megamenu {
  position: relative;
}

.megamenu-trigger {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.megamenu-arrow {
  font-size: 12px;
  transition: transform 0.25s ease;
}

.megamenu-trigger[aria-expanded="true"] .megamenu-arrow {
  transform: rotate(180deg);
}

/* ── Desktop navbar scrollable container ── */
@media (min-width: 992px) {
  .main-navbar-scroll-wrapper {
    position: relative;
    flex: 0 1 auto;
    max-width: calc(100% - 250px);
    overflow: visible;
  }

  .main-navbar-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .main-navbar-scroll-container::-webkit-scrollbar {
    display: none;
  }

  .navbar-scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: none;
    cursor: pointer;
    padding: 12px 8px;
    display: none;
    align-items: center;
    color: #3c3c3c;
    font-size: 16px;
    transition: color 0.2s ease;
    z-index: 10;
    width: 40px;
    height: 100%;
  }

  .navbar-scroll-arrow.visible {
    display: flex;
  }

  .navbar-scroll-arrow--left {
    left: 0;
    background: white;
    justify-content: start;
  }

  .navbar-scroll-arrow--right {
    right: 0;
    background: white;
    justify-content: end;
  }

  .navbar-scroll-arrow:hover {
    color: #1464f4;
  }
}

/* ── Navbar flex override — prevent nav-right from being pushed off screen ── */
@media (min-width: 768px) {
  .navbar-collapse.main-navbar {
    flex-grow: 0;
    flex-shrink: 1;
    max-width: calc(100% - 250px);
  }
}

/* ── Desktop navbar overrides ── */
@media (min-width: 992px) {
  .navbar-main .main-nav {
    gap: 48px;
    flex-wrap: nowrap;
    width: fit-content;
  }

  .navbar-main .main-nav .nav-link {
    font-size: 1.6rem;
    font-weight: 600;
    font-family: "Mulish", sans-serif;
    color: #3c3c3c;
    padding-left: 0;
    padding-right: 0;
    white-space: nowrap;
  }
}

/* ── Active state — current page highlight ── */
.navbar-main .main-nav .nav-link.active,
.navbar-main .main-nav .megamenu-trigger.active {
  color: #1464f4;
}

.megamenu-card--active .megamenu-card__link-primary {
  color: #1464f4;
}

/* ── Ensure navbar-main sits above navbar-secondary when megamenu is open ── */
.navbar-main.megamenu-open {
  z-index: 101;
}

/* ── Desktop dropdown panel ── */
@media (min-width: 992px) {
  .has-megamenu {
    position: static;
    display: flex;
    align-items: center;
  }

  .megamenu-trigger {
    position: relative;
    height: 100%;
  }

  .megamenu-trigger[aria-expanded="true"]::after,
  .megamenu-trigger.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: #1464f4;
  }

  .megamenu-panel {
    position: absolute;
    top: 60px;
    left: 50%;
    width: 100vw;
    max-width: 1440px;
    box-sizing: border-box;
    background: #fff;
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.1);
    padding: 30px 75px;
    z-index: 1010;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
    transition:
      opacity 0.25s ease,
      transform 0.25s ease,
      visibility 0s 0.25s;
  }

  .megamenu-panel[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition:
      opacity 0.25s ease,
      transform 0.25s ease,
      visibility 0s 0s;
  }

  .megamenu-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 48px 30px;
    justify-content: flex-start;
    align-items: flex-start;
    align-content: flex-start;
    padding: 0;
  }

  .megamenu-card {
    width: 300px;
    flex-shrink: 0;
  }

  .megamenu-mobile-sub {
    display: none !important;
  }
}

/* ── Vehicle card — shared ── */
.megamenu-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.megamenu-card__name {
  font-family: "Mulish", sans-serif;
  font-style: normal;
  font-weight: 600;
  font-size: 24px;
  line-height: 150%;
  color: #000000;
  margin: 0;
}

.megamenu-card__logo {
  height: 16px;
  margin: 0 0 -4px;
}

.megamenu-card__logo img {
  height: 100%;
  width: auto;
  object-fit: contain;
}

.megamenu-card__desc {
  font-size: 14px;
  color: #3c3c3c;
  line-height: 1.5;
  margin-bottom: 0;
  font-family: "Mulish", sans-serif;
  font-weight: 600;
  opacity: 0.9;
}

.megamenu-card__image {
  height: 120px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.megamenu-card__image img {
  width: 245px;
  height: 136px;
  object-fit: contain;
}

.megamenu-card__links {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: "Mulish", sans-serif;
  line-height: 1.5;
}

.megamenu-card__link-primary {
  color: #3c3c3c;
  text-decoration: none;
  white-space: nowrap;
}

.megamenu-card__link-primary:hover {
  color: #1464f4;
}

.megamenu-card__separator {
  width: 1px;
  align-self: stretch;
  background: #f7f9f9;
  font-size: 0;
  overflow: hidden;
}

.megamenu-card__link-secondary {
  color: #3c3c3c;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.megamenu-card__link-secondary:hover {
  color: #1464f4;
}

.megamenu-card__link-secondary .icon-arrow-right-up {
  font-size: 14px;
}

/* ── Mobile styles ── */
@media (max-width: 991.98px) {
  .megamenu-panel {
    display: none !important;
  }

  .megamenu-trigger {
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .megamenu-arrow {
    transform: rotate(-90deg);
  }

  .megamenu-trigger[aria-expanded="true"] .megamenu-arrow {
    transform: rotate(0deg);
  }

  .megamenu-mobile-sub {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 1020;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.5, 0, 0, 0.75);
    overflow-y: auto;
  }

  .megamenu-mobile-sub[aria-hidden="false"] {
    transform: translateX(0);
  }

  .megamenu-mobile-sub__header {
    height: 64px;
    background: #f7f9f9;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid #d9e1e2;
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .megamenu-mobile-back {
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 600;
    color: #3c3c3c;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    font-family: "Mulish", sans-serif;
  }

  .megamenu-mobile-sub__title {
    flex: 1;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    color: #3c3c3c;
    margin-right: 60px;
  }

  .megamenu-mobile-sub__list {
    padding: 16px 24px;
  }

  .megamenu-card--mobile {
    width: 100%;
    padding: 24px 0;
    border-bottom: 1px solid #f7f9f9;
  }

  .megamenu-card--mobile:last-child {
    border-bottom: none;
  }

  .megamenu-card--mobile .megamenu-card__image {
    height: auto;
  }

  .megamenu-card--mobile .megamenu-card__image img {
    width: 100%;
    max-height: 160px;
  }

  .megamenu-card--mobile .megamenu-card__links {
    justify-content: space-between;
    width: 100%;
  }
}
