/* TradeAnalyzer selector dropdowns — Market & Language */
:root {
  --ta-sel-border: rgba(148, 163, 184, 0.35);
  --ta-sel-border-active: rgba(251, 191, 36, 0.85);
  --ta-sel-bg: rgba(15, 23, 42, 0.96);
  --ta-sel-bg-hover: rgba(251, 191, 36, 0.12);
  --ta-sel-text: #e2e8f0;
  --ta-sel-muted: #94a3b8;
  --ta-sel-focus: #38bdf8;
  --ta-sel-check: #fbbf24;
}

.ta-sel,
.market-switcher-dropdown,
.lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 10220;
}

.ta-sel-trigger,
.market-current,
.lang-current {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--ta-sel-border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--ta-sel-text);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ta-sel-trigger:hover,
.market-current:hover,
.lang-current:hover {
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(15, 23, 42, 1);
}

.ta-sel-trigger:focus,
.market-current:focus,
.lang-current:focus {
  outline: none;
  box-shadow: none;
}

.ta-sel-trigger:focus-visible,
.market-current:focus-visible,
.lang-current:focus-visible {
  outline: 2px solid var(--ta-sel-focus);
  outline-offset: 3px;
}

.market-switcher-dropdown[data-market="commodities"] .market-current,
.market-switcher-dropdown[data-market="crypto"] .market-current,
.market-switcher-dropdown[data-market="forex"] .market-current,
.market-switcher-dropdown[data-market="markets"] .market-current {
  border-color: var(--ta-sel-border-active);
}

.ta-sel-icon,
.market-current-icon,
.market-option .ta-sel-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.ta-sel-icon svg,
svg.ta-sel-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.market-current-label,
.lang-native {
  max-width: 11ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-code,
.lang-code {
  color: var(--ta-sel-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 650;
}

.ta-sel-caret,
.market-caret,
.lang-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.75;
  margin-inline-start: 2px;
}

.ta-sel-menu,
.market-menu,
.lang-menu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  width: min(340px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 120px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--ta-sel-bg);
  color: var(--ta-sel-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 10300;
}

/* Portaled open menus (appended to body) must always win over page CSS */
.ta-sel-menu.open,
.market-menu.open,
.lang-menu.open,
.market-switcher-dropdown.is-open .market-menu,
.lang-switcher.is-open .lang-menu,
body > .ta-sel-menu.open,
body > .market-menu.open,
body > .lang-menu.open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: none !important;
}

.ta-sel-menu.open,
.market-menu.open,
.market-switcher-dropdown.is-open .market-menu,
body > .ta-sel-menu.open,
body > .market-menu.open {
  display: block !important;
}

/* Language list: single compact column — all 13 locales visible without scroll */
.lang-menu,
body > .lang-menu {
  width: min(280px, calc(100vw - 24px));
  min-width: min(220px, calc(100vw - 24px));
  max-height: none;
  overflow: visible;
  padding: 4px;
}

.lang-menu.open,
body > .lang-menu.open,
.lang-switcher.is-open .lang-menu {
  display: flex !important;
  flex-direction: column;
  gap: 1px;
  align-content: stretch;
}

.ta-sel-option,
.market-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ta-sel-text);
  text-decoration: none;
  text-align: start;
  font-size: 0.88rem;
  cursor: pointer;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 34px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ta-sel-text);
  text-decoration: none;
  text-align: start;
  font-size: 0.82rem;
  cursor: pointer;
  box-sizing: border-box;
}

.lang-option .ta-sel-check {
  width: 12px;
  flex: 0 0 12px;
  font-size: 0.75rem;
}

.lang-option-native {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-option-code {
  font-size: 0.72rem;
  margin-inline-start: auto;
}

@media (max-height: 640px) {
  .lang-option {
    min-height: 30px;
    padding: 3px 10px;
    font-size: 0.78rem;
  }
}

.ta-sel-option:hover,
.ta-sel-option:focus-visible,
.market-option:hover,
.market-option:focus-visible,
.lang-option:hover,
.lang-option:focus-visible {
  background: var(--ta-sel-bg-hover);
  outline: none;
}

.ta-sel-option.is-active,
.market-option.is-active,
.market-option.active,
.lang-option.is-active {
  background: rgba(251, 191, 36, 0.16);
  color: #fff;
  font-weight: 650;
}

.ta-sel-check {
  width: 16px;
  flex: 0 0 16px;
  color: var(--ta-sel-check);
  font-size: 0.85rem;
  opacity: 0;
}

.ta-sel-option.is-active .ta-sel-check,
.market-option.is-active .ta-sel-check,
.lang-option.is-active .ta-sel-check {
  opacity: 1;
}

.ta-sel-option-label,
.lang-option-native {
  flex: 1 1 auto;
  min-width: 0;
}

.ta-sel-option-meta,
.lang-option-code {
  color: var(--ta-sel-muted);
  font-size: 0.78rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.ta-sel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  z-index: 10290;
}

.ta-sel-menu--sheet {
  border-radius: 16px 16px 0 0 !important;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

/* Commodities secondary nav */
.cmd-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.cmd-subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--ta-sel-border);
  color: var(--ta-sel-muted);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
}

.cmd-subnav a:hover,
.cmd-subnav a:focus-visible {
  color: #fff;
  border-color: rgba(251, 191, 36, 0.55);
  outline: none;
}

.cmd-subnav a.is-active,
.cmd-subnav a[aria-current="page"] {
  color: #0b1220;
  background: #fbbf24;
  border-color: #fbbf24;
}

@media (max-width: 720px) {
  .market-current-label.ta-sel-label-wide,
  .lang-label {
    display: none;
  }
  .market-current,
  .lang-current {
    padding: 0 12px;
  }
}

/* Prefer logical properties for RTL */
[dir="rtl"] .ta-sel-menu,
[dir="rtl"] .market-menu,
[dir="rtl"] .lang-menu {
  inset-inline-end: auto;
  inset-inline-start: 0;
}
