.lang-switcher {
  position: relative;
  z-index: 1000;
  flex-shrink: 0;
  margin-left: 0.75rem;
  margin-right: 0;
}

.lang-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2.5rem;
  padding: 0 0.85rem;
  border: 1px solid #e0e0e0;
  border-radius: 0.375rem;
  background: #fff;
  color: #333;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.lang-switcher__btn:hover {
  background: #f8f9fa;
  color: #3898ec;
}

.lang-switcher__btn[aria-expanded="true"] {
  border-color: #3898ec;
  color: #3898ec;
}

.lang-switcher__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.lang-switcher__btn[aria-expanded="true"] .lang-switcher__chevron {
  transform: rotate(180deg);
}

/* Override header ul { display: flex } — vertical dropdown */
header .lang-switcher__list,
.lang-switcher__list {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  left: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  width: max-content;
  min-width: 11.5rem;
  max-width: min(16rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 22rem);
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  border: 1px solid #e0e0e0;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

header .lang-switcher__list[hidden],
.lang-switcher__list[hidden] {
  display: none !important;
}

header .lang-switcher__list li,
.lang-switcher__list li {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  line-height: normal;
}

header .lang-switcher__list a,
.lang-switcher__link {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  border-radius: 0.375rem;
  color: #333;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  direction: ltr;
  transition: background-color 0.15s ease, color 0.15s ease;
}

header .lang-switcher__list a:hover,
.lang-switcher__link:hover {
  background: #f8f9fa;
  color: #3898ec;
}

header .lang-switcher__list a.lang-switcher__item--active,
.lang-switcher__item--active {
  background: rgba(56, 152, 236, 0.1);
  color: #3898ec;
  font-weight: 600;
  pointer-events: none;
}

.header-menu {
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.header-menu > .header-logo {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.header-menu > .navigation-wrapper {
  margin-left: auto;
  flex-shrink: 1;
  min-width: 0;
}

.header-menu > .navigation-wrapper + .lang-switcher {
  margin-left: 0;
  flex-shrink: 0;
}

/* Compact desktop: lang switcher adds width before hamburger kicks in */
@media screen and (max-width: 1300px) {
  .header-menu-item {
    margin-right: 14px;
    font-size: 14px;
  }

  .brand-name {
    font-size: 22px;
  }

  .lang-switcher__btn {
    height: 2.25rem;
    padding: 0 0.65rem;
    font-size: 0.8125rem;
  }
}

@media screen and (max-width: 1200px) {
  .header-menu-item {
    margin-right: 10px;
    font-size: 13px;
  }

  .brand-name {
    font-size: 20px;
  }

  .header-menu-item.get-started {
    padding: 5px 12px;
  }
}

/* Collapse nav earlier than Webflow medium (991px) so switcher fits */
@media screen and (max-width: 1100px) {
  header .w-nav[data-collapse="medium"] .w-nav-menu {
    display: none;
  }

  header .w-nav[data-collapse="medium"] .w-nav-button {
    display: block;
    float: none;
    padding: 10px;
  }

  header .w-nav[data-collapse="medium"] .w-nav-menu.w--open {
    display: block;
  }

  .header-menu {
    position: relative;
    margin-top: 15px;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .header-navigation {
    position: static;
  }

  .header-navigation-box {
    background-color: #fff;
    border-bottom-right-radius: 5px;
    border-bottom-left-radius: 5px;
    margin-left: -15px;
    margin-right: -15px;
    padding: 10px 10px 15px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1100;
  }

  .header-menu-item {
    text-align: center;
    margin: 0 auto 10px;
    font-size: 16px;
  }

  .header-menu-item.login {
    justify-content: center;
  }

  /* Logo left; Español + burger grouped on the right with gap */
  .header-menu > .header-logo {
    order: 1;
  }

  .header-menu > .lang-switcher,
  .header-menu > .navigation-wrapper + .lang-switcher {
    order: 2;
    margin-left: auto;
    margin-right: 0;
    flex-shrink: 0;
  }

  .header-menu > .navigation-wrapper {
    order: 3;
    margin-left: 0;
    flex-shrink: 0;
  }

  .lang-switcher__btn {
    height: 2.25rem;
    padding: 0 0.65rem;
    font-size: 0.8125rem;
  }

  header .lang-switcher__list,
  .lang-switcher__list {
    right: 0;
    left: auto;
  }
}

/* Inside burger menu on narrow phones */
.lang-switcher--mobile {
  display: none;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 0.75rem;
  z-index: 1;
  text-align: left;
}

.lang-switcher--mobile .lang-switcher__btn {
  width: auto;
  min-width: 8.5rem;
  justify-content: space-between;
}

header .lang-switcher--mobile .lang-switcher__list,
.lang-switcher--mobile .lang-switcher__list {
  position: absolute;
  left: 0;
  right: auto;
  transform: none;
  width: max-content;
  min-width: 11.5rem;
  max-width: min(16rem, calc(100vw - 2rem));
  margin-top: 0.4rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

@media screen and (max-width: 450px) {
  .header-menu > .lang-switcher,
  .header-menu > .navigation-wrapper + .lang-switcher {
    display: none !important;
  }

  .lang-switcher--mobile {
    display: block;
  }

  .header-menu > .navigation-wrapper {
    margin-left: auto;
  }

  .brand-name {
    font-size: 18px;
  }
}
