/* ==========================================================================
   NimbleAI — Language switcher
   Utilise les vraies variables du site (--surface, --border, --text, --accent)
   ========================================================================== */

.lang-switcher {
  position: relative;
  display: inline-block;
  font-family: var(--font-body);
}

.lang-switcher__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  max-width: 100%;
}

.lang-switcher__trigger:hover {
  background: var(--surface-2);
}

.lang-switcher__trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lang-switcher__trigger svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

.lang-switcher__trigger span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-switcher__panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: -40px;
  min-width: 190px;
  max-width: calc(100vw - 24px);
  max-height: min(260px, calc(100vh - 24px));
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 14px);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  z-index: 600;
}

/* Variante "s'ouvre vers le bas" — utilisée dans la navbar */
.lang-switcher--down .lang-switcher__panel {
  bottom: auto;
  top: calc(100% + 8px);
}

/* Sur mobile, le trigger est proche du bord gauche de l'écran (menu hamburger) :
   ancrer le panneau par la gauche plutôt que par la droite pour qu'il reste
   dans le viewport au lieu de déborder à gauche. */
@media (max-width: 900px) {
  .lang-switcher__panel {
    left: 0;
    right: auto;
  }
}

/* Dans la sidebar du dashboard, le trigger est TOUJOURS collé au bord gauche
   de l'écran, même sur desktop (sidebar fixe à gauche) — pas seulement sur
   mobile. Avec l'ancrage "right: -40px" par défaut, le panneau déborde donc
   hors du viewport à gauche et une partie de son contenu reste invisible.
   On ancre systématiquement par la gauche dans ce contexte, quelle que soit
   la largeur d'écran. */
.sidebar-lang-row .lang-switcher__panel {
  left: 0;
  right: auto;
  /* Sidebar is 240px with 16px padding each side; cap the panel so a long
     label (e.g. "Português (Brasil)" + its "Beta" badge) can't force it
     wider than the sidebar and spill over the dashboard content. */
  max-width: 200px;
}

.sidebar-lang-row .lang-switcher__row-label {
  white-space: normal;
  line-height: 1.3;
}

.lang-switcher__row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r-md, 9px);
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.lang-switcher__row:hover {
  background: var(--surface-3);
}

.lang-switcher__row.is-active {
  background: var(--accent-low);
  color: var(--accent);
  font-weight: 600;
}

.lang-switcher__row-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-switcher__badge {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--text-3);
  background: var(--border-2);
}

.lang-switcher__panel::-webkit-scrollbar { width: 6px; }
.lang-switcher__panel::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 999px;
}

@media (max-width: 480px) {
  .lang-switcher__panel {
    min-width: 170px;
    max-height: min(240px, calc(100vh - 16px));
  }
}
