/* Accessible Polylang Language Switcher Styles */

.a11ylang-switcher {
  position: relative;
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Screen reader only - visually hidden but accessible */
.a11ylang-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.a11ylang-switcher__button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0px;
  background-color: #fff;
  border: 2px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  color: #333;
  transition: all 0.2s ease;
  min-width: 140px; /* Default width for flag_and_name */
}

/* Adaptive widths based on display mode */
[data-display-mode="flag_only"] .a11ylang-switcher__button {
  min-width: 60px;
  max-width: 60px;
  justify-content: center;
}

[data-display-mode="code_only"] .a11ylang-switcher__button {
  min-width: 80px;
  max-width: 80px;
  justify-content: center;
}

[data-display-mode="name_only"] .a11ylang-switcher__button {
  min-width: 120px;
}

[data-display-mode="flag_and_name"] .a11ylang-switcher__button {
  min-width: 140px;
}

.a11ylang-switcher__button:hover {
  border-color: #999;
  background-color: #f9f9f9;
}

.a11ylang-switcher__button:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
  border-color: #0073aa;
}

.a11ylang-switcher__button[aria-expanded="true"] {
  border-color: #0073aa;
  background-color: #f0f0f0;
}

.a11ylang-switcher__current {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.a11ylang-switcher__icon {
  font-size: 18px;
  line-height: 1;
}

.a11ylang-switcher__text {
  font-weight: 500;
}

.a11ylang-switcher__arrow {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s ease;
  color: #666;
}

.a11ylang-switcher__button[aria-expanded="true"] .a11ylang-switcher__arrow {
  transform: rotate(180deg);
}

.a11ylang-switcher__dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: #fff;
  border: 2px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  min-width: 140px; /* Default width for flag_and_name */
}

/* Adaptive dropdown widths based on display mode */
[data-display-mode="flag_only"] .a11ylang-switcher__dropdown {
  min-width: 60px;
}

[data-display-mode="code_only"] .a11ylang-switcher__dropdown {
  min-width: 80px;
}

[data-display-mode="name_only"] .a11ylang-switcher__dropdown {
  min-width: 120px;
}

[data-display-mode="flag_and_name"] .a11ylang-switcher__dropdown {
  min-width: 140px;
}

.a11ylang-switcher__dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.a11ylang-switcher__dropdown li {
  margin: 0;
  padding: 0;
}

.a11ylang-switcher__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  color: #333;
  text-decoration: none;
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.a11ylang-switcher__link:hover,
.a11ylang-switcher__link:focus {
  background-color: #f0f0f0;
  outline: none;
}

.a11ylang-switcher__link[aria-current="page"] {
  background-color: #e8f4f8;
  color: #0073aa;
  font-weight: 600;
  pointer-events: none;
}

.a11ylang-switcher__link[aria-current="page"]::after {
  content: "✓";
  margin-left: auto;
  color: #0073aa;
}

.a11ylang-switcher__flag {
  font-size: 18px;
  line-height: 1;
}

.a11ylang-switcher__lang-name {
  flex: 1;
}

.a11ylang-switcher__lang-code {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .a11ylang-switcher__button {
    padding: 0px;
    font-size: 14px;
  }

  /* Adaptive mobile widths */
  [data-display-mode="flag_only"] .a11ylang-switcher__button {
    min-width: 50px;
    max-width: 50px;
  }

  [data-display-mode="code_only"] .a11ylang-switcher__button {
    min-width: 70px;
    max-width: 70px;
  }

  [data-display-mode="name_only"] .a11ylang-switcher__button {
    min-width: 100px;
  }

  [data-display-mode="flag_and_name"] .a11ylang-switcher__button {
    min-width: 110px;
  }

  /* Adaptive mobile dropdown widths */
  [data-display-mode="flag_only"] .a11ylang-switcher__dropdown {
    min-width: 50px;
  }

  [data-display-mode="code_only"] .a11ylang-switcher__dropdown {
    min-width: 70px;
  }

  [data-display-mode="name_only"] .a11ylang-switcher__dropdown {
    min-width: 100px;
  }

  [data-display-mode="flag_and_name"] .a11ylang-switcher__dropdown {
    min-width: 120px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .a11ylang-switcher__button {
    border-width: 3px;
  }

  .a11ylang-switcher__button:focus {
    outline-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .a11ylang-switcher__button,
  .a11ylang-switcher__dropdown,
  .a11ylang-switcher__arrow,
  .a11ylang-switcher__link {
    transition: none;
  }
}
