/* Language switcher + theme toggle (shared header controls) */
.header-controls {
  flex-shrink: 0;
  margin-left: 0.25rem;
}

@media (min-width: 992px) {
  .app-navbar-actions .header-controls {
    margin-left: 0.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--hc-separator, #e2e8f0);
  }
}

[data-theme="dark"] .app-navbar-actions .header-controls {
  --hc-separator: #334155;
}

.lang-switcher-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--hc-surface, #fff);
  border: 1px solid var(--hc-border, #e2e8f0);
  color: var(--hc-text, #334155);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  box-shadow: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.lang-switcher-btn:hover,
.lang-switcher-btn:active,
.lang-switcher-btn:focus,
.lang-switcher-btn:focus-visible {
  outline: none;
  box-shadow: none;
}

.lang-switcher-btn:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.35);
  outline-offset: 2px;
}

.lang-switcher-btn::after {
  margin-left: 0.2rem;
}

.lang-switcher-btn:hover {
  background: var(--hc-surface-hover, #f8fafc);
  border-color: var(--hc-border-hover, #c7d2fe);
}

.lang-switcher-menu {
  min-width: 10rem;
  font-size: 0.85rem;
}

.lang-switcher-menu .dropdown-item.active {
  background: var(--hc-active-bg, #eef2ff);
  color: var(--hc-active-text, #4338ca);
  font-weight: 600;
}

/* Theme toggle — pill switch (sun / moon) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  box-shadow: none;
  outline: none;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover,
.theme-toggle:active,
.theme-toggle:focus,
.theme-toggle:focus-visible {
  background: transparent;
  border: none;
  box-shadow: none;
  outline: none;
}

.theme-toggle:focus-visible .theme-toggle-track {
  outline: 2px solid rgba(79, 70, 229, 0.4);
  outline-offset: 2px;
}

.theme-toggle-track {
  position: relative;
  display: block;
  width: 52px;
  height: 28px;
  border-radius: 999px;
  background: #e8eaf3;
  border: 1px solid #d8dce8;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s ease;
}

.theme-icon-light,
.theme-icon-dark {
  position: absolute;
  font-size: 0.72rem;
  line-height: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.theme-icon-light {
  color: #f59e0b;
  opacity: 1;
  transform: scale(1);
}

.theme-icon-dark {
  color: #38bdf8;
  opacity: 0;
  transform: scale(0.6);
}

[data-theme="dark"] .theme-toggle-track {
  background: #1e293b;
  border-color: #334155;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(24px);
  background: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .theme-icon-light {
  opacity: 0;
  transform: scale(0.6);
}

[data-theme="dark"] .theme-icon-dark {
  opacity: 1;
  transform: scale(1);
}

[data-theme="dark"] {
  --hc-surface: #1e293b;
  --hc-border: #475569;
  --hc-text: #e2e8f0;
  --hc-surface-hover: #334155;
  --hc-border-hover: #64748b;
  --hc-active-bg: #312e81;
  --hc-active-text: #c7d2fe;
}

/* Mobile collapsed menu — без чёрного UA-контура и лишних рамок */
@media (max-width: 991.98px) {
  .header-controls {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0.25rem 0;
  }

  .navbar-nav .nav-item > .header-controls {
    justify-content: center;
    width: 100%;
  }

  .app-navbar-actions .header-controls {
    border-left: none !important;
    padding-left: 0 !important;
    margin-left: 0 !important;
  }

  .header-controls .lang-switcher-btn,
  .header-controls .theme-toggle {
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
  }

  .header-controls .lang-switcher-btn:active {
    transform: scale(0.98);
  }
}

/* Navbar controls не наследуют глобальные стили кнопок страниц */
.app-navbar .header-controls .theme-toggle,
.app-navbar .header-controls .lang-switcher-btn,
.navbar .header-controls .theme-toggle,
.navbar .header-controls .lang-switcher-btn {
  background: var(--hc-surface, #fff);
  color: var(--hc-text, #334155);
}

.app-navbar .header-controls .theme-toggle,
.navbar .header-controls .theme-toggle {
  background: transparent !important;
}

/* Marketing navbar: nav-link ::before не должен влиять на controls */
.navbar .header-controls .lang-switcher-btn::before,
.navbar .header-controls .theme-toggle::before {
  display: none !important;
  content: none !important;
}

.navbar .nav-item > .header-controls .lang-switcher-btn {
  width: auto;
  margin-top: 0;
}
