/* Reusable flag-based language dropdown.
   Enhances a native <select> (kept in the DOM, visually hidden) with a custom
   trigger + menu that shows a flag next to each language. See
   static/js/languageFlagSelect.js. */

.lfs {
  position: relative;
  display: inline-block;
  font-family: var(--font-family, inherit);
  text-align: left;
    width: 100%;
    max-width: 300px;
}

/* Native select is kept for value + change events but hidden from view. */
.lfs-native {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.lfs__trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--surface-border, rgba(15, 23, 42, 0.12));
  border-radius: 10px;
  background: var(--surface, #fff);
  color: var(--font-black, #1e293b);
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast, 0.15s) ease,
    box-shadow var(--transition-fast, 0.15s) ease,
    background-color var(--transition-fast, 0.15s) ease;
}
.lfs__trigger:hover {
  border-color: var(--brand, #6366f1);
}
.lfs__trigger:focus-visible,
.lfs.is-open .lfs__trigger {
  border-color: var(--brand, #6366f1);
  box-shadow: 0 0 0 3px var(--brand-soft, rgba(99, 102, 241, 0.15));
}

.lfs__flag {
  width: 20px;
  height: 14px;
  border-radius: 3px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.lfs__label {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lfs__chevron {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: var(--font-gray, #64748b);
  transition: transform var(--transition-fast, 0.15s) ease;
}
.lfs.is-open .lfs__chevron {
  transform: rotate(180deg);
}

.lfs__menu {
  position: absolute;
  left: 0;
  right: 0;
    bottom: 100%;
  z-index: 5;
  margin: 6px 0 0;
  padding: 6px;
    box-sizing: border-box;
  list-style: none;
    width: 100%;
    min-width: 300px;
    height: auto;
    overflow-y: auto;
    max-height: 500px;
  background: var(--surface, #fff);
  border: 1px solid var(--surface-border, rgba(15, 23, 42, 0.12));
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.lfs.is-open .lfs__menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Open upwards when there isn't enough room below (set by JS). */
.lfs--up .lfs__menu {
  top: auto;
  bottom: 100%;
  margin: 0 0 6px;
  transform-origin: bottom center;
  transform: translateY(6px) scale(0.98);
}
.lfs--up.is-open .lfs__menu {
  transform: translateY(0) scale(1);
}

.lfs__search-wrap {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0 0 6px;
  background: var(--surface, #fff);
}

.lfs__search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--surface-border, rgba(15, 23, 42, 0.12));
  border-radius: 8px;
  background: var(--surface-secondary, rgba(15, 23, 42, 0.04));
  color: var(--font-black, #1e293b);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast, 0.15s) ease,
    box-shadow var(--transition-fast, 0.15s) ease;
}
.lfs__search:focus {
  border-color: var(--brand, #6366f1);
  box-shadow: 0 0 0 3px var(--brand-soft, rgba(99, 102, 241, 0.15));
}

.lfs__option.is-filtered {
  display: none;
}

.lfs__option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--font-black, #1e293b);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.lfs__option:hover,
.lfs__option.is-active {
  background: var(--surface-secondary, rgba(99, 102, 241, 0.08));
}
.lfs__option.is-selected {
  font-weight: 700;
}
.lfs__option.is-selected .lfs__check {
  opacity: 1;
}
.lfs__option .lfs__check {
  margin-left: auto;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--brand, #6366f1);
  opacity: 0;
}
