/* Desplazamiento suave con offset para header fijo */
[id] {
  scroll-margin-top: 95px;
}

.topheader {
  position: fixed;
  background-color: #000;
  left: 0;
  height: 90px;
  top: 0;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  max-width: 1400px;
  width: 96%;
  margin: 0 auto;
  height: 100%;
  box-sizing: border-box;
  position: relative;
}

/* Logo (Izquierda) */
.logo {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  margin-right: 15px;
  text-decoration: none;
}
.logo img {
  width: 180px;
  max-width: 100%;
  max-height: 65px;
  object-fit: contain;
  display: block;
}

/* Menú Principal (Centro / Derecha) */
.menu {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.menu li.nav-item {
  display: inline-flex;
  align-items: center;
  padding: 0 3px;
  flex-shrink: 0;
}

.menu a {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  font-size: clamp(12.5px, 0.9vw, 14.5px);
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
  letter-spacing: 0.3px;
  text-decoration: none;
  border-radius: 6px;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

/* Botón y Desplegable 'MÁS ▾' (Priority+) */
.nav-item-more {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  flex-shrink: 0;
}

.more-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  font-size: clamp(12px, 0.85vw, 13.5px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border: 1.5px solid currentColor;
  border-radius: 20px;
  background: transparent;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.more-btn svg.more-icon {
  transition: transform 0.25s ease;
  display: inline-block;
  vertical-align: middle;
}

.nav-item-more.open .more-btn svg.more-icon {
  transform: rotate(180deg);
}

.more-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 220px;
  max-width: 320px;
  list-style: none;
  margin: 0;
  padding: 8px 0;
  border-radius: 10px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: none;
  z-index: 1200;
  max-height: 70vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.more-dropdown.show {
  display: block;
  animation: dropdownFade 0.2s ease-out;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.more-dropdown li {
  display: block;
  width: 100%;
}

.more-dropdown li a {
  display: block;
  width: 100%;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  text-transform: uppercase;
  text-decoration: none;
  white-space: normal;
  line-height: 1.4;
  border-radius: 0;
  box-sizing: border-box;
  text-align: left;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Acciones a la Derecha y Selector de Idioma (Siempre visible en la esquina derecha) */
.header-right-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  margin-left: 15px;
  position: relative;
  z-index: 1050;
}

.lang-selector {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  background: transparent;
  border: 1.5px solid currentColor;
  border-radius: 20px;
  cursor: pointer;
  font-size: clamp(12px, 0.85vw, 13.5px);
  font-weight: 600;
  letter-spacing: 0.3px;
  outline: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.lang-flag-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.lang-flag-box img {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

.lang-caret {
  transition: transform 0.2s ease;
  display: inline-block;
  vertical-align: middle;
}

.lang-selector.open .lang-caret {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 190px;
  list-style: none;
  margin: 0;
  padding: 6px 0;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: none;
  z-index: 1250;
}

.lang-dropdown.show {
  display: block;
  animation: dropdownFade 0.2s ease-out;
}

.lang-dropdown li {
  display: block;
  width: 100%;
}

.lang-dropdown a.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.lang-opt-abbr {
  font-size: 11px;
  opacity: 0.7;
  margin-left: auto;
}

/* Botones de menú móvil */
.open-menu,
.close-menu {
  display: none;
}

.mobile-lang-item {
  display: none;
}

/* Tablet Portrait y Smartphone (<= 950px) */
@media (max-width: 950px) {
  [id] {
    scroll-margin-top: 85px;
  }

  .topheader {
    height: 80px;
  }

  .topnav {
    width: 100%;
    padding: 0 15px;
  }

  .logo img {
    width: 145px;
    max-height: 52px;
  }

  .header-right-actions {
    gap: 8px;
    margin-left: auto;
  }

  .lang-btn {
    padding: 5px 10px;
    font-size: 12px;
    gap: 6px;
  }

  .lang-flag-box img {
    width: 18px;
    height: 12px;
  }

  /* Menú desplegable tipo Drawer a pantalla completa */
  .menu {
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 25px 20px 90px 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    box-sizing: border-box;
    z-index: 2000;
  }

  .menu.menu_opened {
    opacity: 1;
    pointer-events: all;
  }

  .menu li.nav-item {
    width: 100%;
    max-width: 380px;
    padding: 4px 0;
    text-align: center;
    display: block !important;
  }

  .menu li.nav-item a {
    display: block;
    width: 100%;
    padding: 12px 18px;
    font-size: 17px;
    line-height: 1.4;
    text-align: center;
    box-sizing: border-box;
  }

  /* En móvil, el botón MÁS no se usa porque todos los apartados se listan directamente en el cajón con scroll */
  .nav-item-more {
    display: none !important;
  }

  .open-menu,
  .close-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px;
  }

  .close-menu {
    align-self: flex-end;
    margin-bottom: 10px;
  }

  .close-menu img {
    width: 32px;
    height: 32px;
  }

  .open-menu img {
    width: 38px;
    height: 38px;
  }

  .open-menu:focus:not(:focus-visible),
  .close-menu:focus:not(:focus-visible) {
    outline: none;
  }

  /* Idiomas dentro del cajón móvil */
  .mobile-lang-item {
    display: block;
    width: 100%;
    max-width: 380px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }

  .mobile-lang-selector {
    display: flex;
    justify-content: center;
    gap: 12px;
  }

  .mobile-lang-opt {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
  }
}

/* Teléfonos muy pequeños (<= 420px) */
@media (max-width: 420px) {
  .logo img {
    width: 120px;
    max-height: 45px;
  }
  .lang-name-text {
    display: none;
  }
  .lang-btn {
    padding: 5px 8px;
  }
}