/* ============================================================
   F-Tech Translate — Frontend Language Switcher
   Pasuje do headera bmwparts24.pl (cls-bmwc-naglowek)
   Kolor aktywnego: #1A6DCC (BMW niebieski) + accent #FD7900 (F-Tech pomarańcz)
   ============================================================ */

.ftech-lang-switcher {
  --ftech-ls-primary: #1A6DCC;
  --ftech-ls-primary-hover: #0f5baf;
  --ftech-ls-accent: #FD7900;
  --ftech-ls-text: #2d3339;
  --ftech-ls-bg: #ffffff;
  --ftech-ls-border: #e9ebee;
  --ftech-ls-hover-bg: #f5f6f8;
  --ftech-ls-shadow: 0 4px 16px rgba(0,0,0,0.08);

  position: relative;
  display: inline-flex;
  align-items: center;
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  color: var(--ftech-ls-text);
  box-sizing: border-box;
}
.ftech-lang-switcher *,
.ftech-lang-switcher *::before,
.ftech-lang-switcher *::after {
  box-sizing: border-box;
}

/* Wrapper w customowym headerze .cls-bmwc-naglowek__akcje */
.cls-bmwc-naglowek__lang-wrap {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid rgba(0,0,0,0.08);
  align-self: center;
}
@media (max-width: 768px) {
  .cls-bmwc-naglowek__lang-wrap {
    margin-left: 2px;
    padding-left: 8px;
  }
}

/* ---------- Toggle button (dropdown + compact) ---------- */
.ftech-lang-switcher__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease;
}
.ftech-lang-switcher__toggle:hover,
.ftech-lang-switcher__toggle:focus-visible {
  background: var(--ftech-ls-hover-bg);
  border-color: var(--ftech-ls-border);
  outline: none;
}
.ftech-lang-switcher__toggle[aria-expanded="true"] {
  background: var(--ftech-ls-hover-bg);
  border-color: var(--ftech-ls-primary);
}

/* ---------- Flag ---------- */
.ftech-lang-switcher__flag {
  display: inline-flex;
  width: 20px;
  height: 14px;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.ftech-lang-switcher__flag svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Code (EN/DE/RU/UK) ---------- */
.ftech-lang-switcher__code {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.03em;
}

/* ---------- Chevron ---------- */
.ftech-lang-switcher__chevron {
  opacity: 0.5;
  transition: transform 200ms ease, opacity 160ms ease;
  flex-shrink: 0;
}
.ftech-lang-switcher__toggle:hover .ftech-lang-switcher__chevron,
.ftech-lang-switcher__toggle[aria-expanded="true"] .ftech-lang-switcher__chevron {
  opacity: 1;
}
.ftech-lang-switcher__toggle[aria-expanded="true"] .ftech-lang-switcher__chevron {
  transform: rotate(180deg);
}

/* ---------- Dropdown list ---------- */
.ftech-lang-switcher__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  padding: 6px;
  margin: 0;
  list-style: none;
  background: var(--ftech-ls-bg);
  border: 1px solid var(--ftech-ls-border);
  border-radius: 8px;
  box-shadow: var(--ftech-ls-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 180ms ease, visibility 180ms, transform 180ms ease;
  z-index: 9999;
}
.ftech-lang-switcher--align-left .ftech-lang-switcher__list {
  right: auto;
  left: 0;
}

/* Hover open (desktop only — urządzenia z precyzyjnym wskaźnikiem) */
@media (hover: hover) and (pointer: fine) {
  .ftech-lang-switcher:hover .ftech-lang-switcher__list,
  .ftech-lang-switcher:focus-within .ftech-lang-switcher__list {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .ftech-lang-switcher:hover .ftech-lang-switcher__toggle,
  .ftech-lang-switcher:focus-within .ftech-lang-switcher__toggle {
    background: var(--ftech-ls-hover-bg);
    border-color: var(--ftech-ls-primary);
  }
  .ftech-lang-switcher:hover .ftech-lang-switcher__chevron,
  .ftech-lang-switcher:focus-within .ftech-lang-switcher__chevron {
    opacity: 1;
    transform: rotate(180deg);
  }
}

/* Click open (mobile + fallback dla JS) */
.ftech-lang-switcher[aria-expanded="true"] .ftech-lang-switcher__list,
.ftech-lang-switcher.is-open .ftech-lang-switcher__list {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.ftech-lang-switcher__item {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ftech-lang-switcher__list .ftech-lang-switcher__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--ftech-ls-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 140ms ease, color 140ms ease;
}
.ftech-lang-switcher__list .ftech-lang-switcher__link:hover,
.ftech-lang-switcher__list .ftech-lang-switcher__link:focus-visible {
  background: var(--ftech-ls-hover-bg);
  color: var(--ftech-ls-primary);
  outline: none;
}
.ftech-lang-switcher__item.is-active .ftech-lang-switcher__link {
  color: var(--ftech-ls-primary);
  font-weight: 600;
  pointer-events: none;
  position: relative;
}
.ftech-lang-switcher__item.is-active .ftech-lang-switcher__link::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ftech-ls-accent);
  transform: translateY(-50%);
}
.ftech-lang-switcher__name {
  font-size: 14px;
  color: inherit;
}

/* ---------- Inline variant ---------- */
.ftech-lang-switcher--inline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.ftech-lang-switcher--inline .ftech-lang-switcher__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ftech-ls-text);
  transition: background 140ms ease;
}
.ftech-lang-switcher--inline .ftech-lang-switcher__link:hover {
  background: var(--ftech-ls-hover-bg);
}
.ftech-lang-switcher--inline .ftech-lang-switcher__link.is-active {
  background: var(--ftech-ls-primary);
  color: #fff;
  pointer-events: none;
}

/* ---------- Compact variant ---------- */
.ftech-lang-switcher--compact .ftech-lang-switcher__toggle {
  padding: 6px 8px;
}
.ftech-lang-switcher--compact .ftech-lang-switcher__list .ftech-lang-switcher__link {
  padding: 6px 10px;
}

/* ---------- Mobile adjustments ---------- */
@media (max-width: 768px) {
  .ftech-lang-switcher__code {
    font-size: 12px;
  }
  .ftech-lang-switcher__toggle {
    padding: 4px 6px;
    gap: 6px;
  }
  .ftech-lang-switcher__flag {
    width: 18px;
    height: 12px;
  }
  .ftech-lang-switcher__list {
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
  }
  .ftech-lang-switcher[aria-expanded="true"] .ftech-lang-switcher__list,
  .ftech-lang-switcher.is-open .ftech-lang-switcher__list {
    transform: translateX(-50%) translateY(0);
  }
}

/* ---------- High contrast / accessibility ---------- */
.ftech-lang-switcher__link:focus-visible {
  outline: 2px solid var(--ftech-ls-primary);
  outline-offset: 2px;
}

/* Hide by default until JS initialized — prevents FOUC */
.ftech-lang-switcher[hidden] {
  display: none !important;
}
