/* ════════════════════════════════════════════════════
   Incode Translate Master — Language Switcher Styles
   All display modes: dropdown, list, flags, inline
   ════════════════════════════════════════════════════ */

/* ── Common ────────────────────────────────────────── */
.wptm-switcher { font-family: inherit; }
.wptm-flag { display: inline-block; line-height: 1; }
.wptm-flag-lg { font-size: 22px; }
.wptm-lang-name { display: inline-block; }
.screen-reader-text { position: absolute; clip: rect(1px,1px,1px,1px); width: 1px; height: 1px; overflow: hidden; }

/* ── Vertical layout modifier ──────────────────────── */
.wptm-vertical { flex-direction: column !important; align-items: flex-start !important; }

/* ════════════════════════════════════════════════════
   DROPDOWN
   ════════════════════════════════════════════════════ */
.wptm-switcher--dropdown {
  position: relative;
  display: inline-block;
}

.wptm-switcher__toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  background: #fff;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  white-space: nowrap;
}
.wptm-switcher__toggle:hover,
.wptm-switcher--dropdown.open .wptm-switcher__toggle {
  border-color: #5C6AC4;
  box-shadow: 0 0 0 3px rgba(92,106,196,.12);
}
.wptm-switcher__toggle:focus-visible {
  outline: 2px solid #5C6AC4;
  outline-offset: 2px;
}

.wptm-chevron {
  margin-left: 2px;
  transition: transform .2s ease;
  flex-shrink: 0;
  opacity: .6;
}
.wptm-switcher--dropdown.open .wptm-chevron,
.wptm-switcher--dropdown:focus-within .wptm-chevron {
  transform: rotate(180deg);
}

.wptm-switcher__dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 190px;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  list-style: none;
  margin: 0;
  padding: 6px;
  z-index: 99999;
}
/* Open via JS class or :focus-within */
.wptm-switcher--dropdown.open .wptm-switcher__dropdown,
.wptm-switcher--dropdown:focus-within .wptm-switcher__dropdown {
  display: block;
  animation: wptm-dropdown-in .12s ease;
}
@keyframes wptm-dropdown-in {
  from { opacity:0; transform: translateY(-4px); }
  to   { opacity:1; transform: none; }
}

/* Align dropdown to the right when near viewport edge */
.wptm-switcher--dropdown.wptm-align-right .wptm-switcher__dropdown {
  left: auto;
  right: 0;
}

.wptm-switcher__item { list-style: none; }
.wptm-switcher__item a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  text-decoration: none;
  color: #374151;
  font-size: 14px;
  transition: background .1s, color .1s;
  white-space: nowrap;
}
.wptm-switcher__item a:hover {
  background: #F3F4F6;
  color: #1F2937;
}
.wptm-switcher__item--active a {
  background: rgba(92,106,196,.1);
  color: #5C6AC4;
  font-weight: 600;
}
.wptm-check {
  margin-left: auto;
  color: #2ECC71;
  font-weight: 700;
}

/* ════════════════════════════════════════════════════
   LIST
   ════════════════════════════════════════════════════ */
.wptm-switcher--list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wptm-switcher__list-item a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  text-decoration: none;
  color: inherit;
  font-size: 14px;
  border-radius: 5px;
  transition: color .15s;
}
.wptm-switcher__list-item a:hover { color: #5C6AC4; }
.wptm-switcher__list-item.wptm-current-lang a {
  font-weight: 700;
  color: #5C6AC4;
}

/* ════════════════════════════════════════════════════
   FLAGS
   ════════════════════════════════════════════════════ */
.wptm-switcher--flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.wptm-flag-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  opacity: .5;
  transition: opacity .15s, transform .15s;
  font-size: 24px;
  border-radius: 4px;
  padding: 2px;
}
.wptm-flag-link:hover { opacity: .85; transform: scale(1.15); }
.wptm-flag-link--active { opacity: 1; }
.wptm-flag-link--active:after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  background: #5C6AC4;
  border-radius: 1px;
  position: absolute;
  bottom: -3px;
  left: 0;
}
.wptm-flag-link { position: relative; }

/* ════════════════════════════════════════════════════
   INLINE ( ES | EN | FR )
   ════════════════════════════════════════════════════ */
.wptm-switcher--inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.wptm-inline-lang {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: inherit;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color .15s;
  white-space: nowrap;
}
.wptm-inline-lang:hover { color: #5C6AC4; }
.wptm-inline-lang--active { font-weight: 700; color: #5C6AC4; }

.wptm-sep {
  color: #D1D5DB;
  font-weight: 300;
  user-select: none;
}

/* ════════════════════════════════════════════════════
   NAV MENU integration
   ════════════════════════════════════════════════════ */
.wptm-nav-switcher { list-style: none; }
.wptm-nav-switcher > .wptm-switcher--dropdown { display: block; }

/* Align dropdown up when in footer menus */
.wptm-nav-switcher.wptm-menu-up .wptm-switcher__dropdown {
  top: auto;
  bottom: calc(100% + 5px);
}

/* ════════════════════════════════════════════════════
   Elementor integration extras
   ════════════════════════════════════════════════════ */
.elementor-widget-wptm_language_switcher .wptm-switcher--dropdown { display: inline-block; }

/* In-menu style when placed inside a nav */
.wptm-in-nav.wptm-switcher--dropdown .wptm-switcher__toggle {
  background: transparent;
  border-color: transparent;
  padding: 4px 8px;
}
.wptm-in-nav.wptm-switcher--dropdown .wptm-switcher__toggle:hover {
  background: rgba(0,0,0,.05);
  border-color: transparent;
  box-shadow: none;
}


/* ════════════════════════════════════════════════════
   MUCHOS IDIOMAS — el desplegable no crece sin fin
   ════════════════════════════════════════════════════
   Con 15 o 20 idiomas la lista vertical se salía de la pantalla y había que
   hacer scroll a ciegas por encima del diseño. En escritorio se le pone tope
   de alto con scroll propio y, a partir de 8 idiomas, dos columnas. */
.wptm-switcher__dropdown {
  max-height: min(360px, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.wptm-switcher--dropdown.wptm-muchos .wptm-switcher__dropdown {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  min-width: 320px;
}
.wptm-switcher--dropdown.wptm-muchos.open .wptm-switcher__dropdown,
.wptm-switcher--dropdown.wptm-muchos:focus-within .wptm-switcher__dropdown { display: grid; }

/* ════════════════════════════════════════════════════
   MÓVIL — hoja a pantalla completa con rejilla de 3
   ════════════════════════════════════════════════════
   En un teléfono el desplegable clásico es inservible: cuelga de la cabecera,
   se sale por el borde derecho y con muchos idiomas ocupa más que la pantalla.
   El JS (assets/js/switcher.js) lo saca del encabezado y lo mete en una hoja
   anclada abajo, con los idiomas en rejilla de hasta 3 por fila.

   La supresión del `:focus-within` va condicionada a `.wptm-switcher-js` en
   el <html>, que pone el propio guion: si el JS no llegara a cargar, el móvil
   se queda con el desplegable de siempre en vez de quedarse SIN selector. */
/* Con el guion cargado manda la clase `.open` y solo ella. El `:focus-within`
   se queda como respaldo para quien navegue sin JavaScript; si siguiera activo
   con JS, el desplegable no se podría cerrar pulsando otra vez el botón —el
   botón conserva el foco— y es justo el fallo que se veía. */
.wptm-switcher-js .wptm-switcher--dropdown:focus-within:not(.open) > .wptm-switcher__dropdown { display: none; }

@media (max-width: 767px) {
  .wptm-switcher-js .wptm-switcher--dropdown:focus-within > .wptm-switcher__dropdown,
  .wptm-switcher-js .wptm-switcher--dropdown.open > .wptm-switcher__dropdown { display: none; }
}

body.wptm-hoja-abierta { overflow: hidden !important; }

.wptm-hoja-fondo {
  position: fixed;
  inset: 0;
  z-index: 999998;
  background: rgba(17, 17, 27, .55);
  animation: wptm-fundido .16s ease;
}
.wptm-hoja {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  max-height: 86vh;
  background: #fff;
  color: #1F2937;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
  padding: 8px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  animation: wptm-hoja-sube .2s cubic-bezier(.22, 1, .36, 1);
}
@keyframes wptm-fundido { from { opacity: 0; } to { opacity: 1; } }
@keyframes wptm-hoja-sube { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .wptm-hoja, .wptm-hoja-fondo { animation: none; }
}

.wptm-hoja__asa {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: #D1D5DB;
  margin: 2px auto 10px;
  flex: 0 0 auto;
}
.wptm-hoja__cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}
.wptm-hoja__titulo {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: #1F2937;
}
.wptm-hoja__cerrar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: #F3F4F6;
  color: #4B5563;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.wptm-hoja__cerrar:hover { background: #E5E7EB; }

/* La lista es la MISMA <ul> del desplegable, movida aquí dentro: así no hay
   un segundo juego de enlaces que mantener ni se duplica el marcado. */
.wptm-hoja .wptm-switcher__dropdown {
  display: grid !important;
  position: static;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 2px 0 4px;
  min-width: 0;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
  overflow-y: auto;
  animation: none;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 340px) {
  .wptm-hoja .wptm-switcher__dropdown { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.wptm-hoja .wptm-switcher__item a {
  position: relative;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  min-height: 78px;
  padding: 12px 6px;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.25;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  background: #fff;
}
.wptm-hoja .wptm-switcher__item--active a {
  border-color: #5C6AC4;
  background: rgba(92, 106, 196, .08);
}
.wptm-hoja .wptm-flag { font-size: 26px; }
.wptm-hoja .wptm-flag-svg { width: 1.5em; height: 1em; }
.wptm-hoja .wptm-check {
  position: absolute;
  top: 5px;
  right: 7px;
  margin: 0;
  font-size: 12px;
}

/* Buscador de la hoja (solo aparece a partir de 8 idiomas). */
.wptm-hoja__buscar { flex: 0 0 auto; margin-bottom: 10px; }
.wptm-hoja__campo {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  font-size: 16px; /* 16px o iOS hace zoom al enfocar el campo */
  font-family: inherit;
  color: #1F2937;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  -webkit-appearance: none;
  appearance: none;
}
.wptm-hoja__campo:focus {
  outline: none;
  border-color: #5C6AC4;
  box-shadow: 0 0 0 3px rgba(92, 106, 196, .12);
}
.wptm-hoja__vacio { margin: 8px 2px 0; font-size: 13px; color: #6B7280; }
