.language-selector {
  position: relative;
  display: inline-block;
}

.language-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm, 8px);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: var(--font-size-base, 0.875rem);
  font-weight: var(--font-weight-medium, 500);

  &:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
  }

  .language-flag {
    width: 20px;
    height: 20px;
    display: inline-block;
    border-radius: 2px;
  }

  .language-code {
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .dropdown-arrow {
    transition: transform 0.3s ease;
    opacity: 0.7;

    &.rotated {
      transform: rotate(180deg);
    }
  }
}

.language-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--card-bg, #1a1a1a);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 1000;
  overflow: hidden;

  &.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

.language-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: var(--font-size-base, 0.875rem);
  text-align: left;

  &:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.05);
  }

  &.active {
    background: rgba(255, 255, 255, 0.1);
    font-weight: var(--font-weight-semibold, 600);
  }

  &.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
  }

  .option-flag {
    width: 24px;
    height: 24px;
    display: inline-block;
    border-radius: 3px;
  }

  .option-name {
    flex: 1;
  }
}

// Light theme adjustments
:host-context(.alt-header),
:host-context(.header) {
  .language-button {
    border-color: rgba(0, 0, 0, 0.2);
    color: #333333;
    
    &:hover {
      background: rgba(0, 0, 0, 0.05);
      border-color: rgba(0, 0, 0, 0.3);
    }
  }
}

:host-context(.light-theme) {
  .language-button {
    border-color: rgba(0, 0, 0, 0.2);
    color: #333333;
    
    &:hover {
      background: rgba(0, 0, 0, 0.05);
      border-color: rgba(0, 0, 0, 0.3);
    }
  }

  .language-dropdown {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  }

  .language-option {
    color: #333333;
    
    &:hover:not(.disabled) {
      background: rgba(0, 0, 0, 0.05);
    }

    &.active {
      background: rgba(0, 0, 0, 0.1);
    }
  }
}

// platform header specific styles
:host-context(.platform-header),
:host-context(.platform-mobile-menu) {
  .language-selector {
    width: 56px;
    height: 28px;
  }

  .language-button {
    width: 100%;
    height: 100%;
    padding: 4px;
    gap: 4px;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid #677b78;
    border-radius: var(--radius-sm, 8px);
    color: #1e3c38;
    justify-content: center;
    
    &:hover {
      background: rgba(255, 255, 255, 0.5);
      border-color: #677b78;
    }

    .language-flag {
      display: none;
    }

    .language-code {
      font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      font-weight: var(--font-weight-medium, 500);
      font-size: var(--font-size-md, 0.9375rem);
      color: #1e3c38;
      letter-spacing: 0;
      line-height: 1;
    }

    .dropdown-arrow {
      display: block;
      width: 7px;
      height: 10px;
      opacity: 1;
      
      path {
        stroke: #1e3c38;
      }
    }
  }

  .language-dropdown {
    background: #ffffff;
    border-color: #d3dad9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  .language-option {
    color: #1e3c38;
    
    &:hover:not(.disabled) {
      background: rgba(161, 180, 181, 0.2);
    }

    &.active {
      background: rgba(73, 118, 113, 0.1);
    }
  }
}

// Mobile responsiveness
@media (max-width: 768px) {
  .language-button {
    padding: 6px 10px;
    font-size: var(--font-size-sm, 0.8125rem);

    .language-flag {
      width: 18px;
      height: 18px;
    }
  }

  .language-dropdown {
    min-width: 160px;
  }

  .language-option {
    padding: 10px 14px;
    font-size: var(--font-size-sm, 0.8125rem);

    .option-flag {
      width: 20px;
      height: 20px;
    }
  }

  :host-context(.platform-header),
  :host-context(.platform-mobile-menu) {
    .language-selector {
      width: 56px;
      height: 28px;
    }

    .language-button .language-code {
      font-size: var(--font-size-xl, 1.125rem);
    }
  }
}

// Inside mobile menu: use inline dropdown instead of absolute
// to avoid being clipped by overflow: hidden on the menu panel
:host-context(.platform-mobile-menu),
:host-context(.platform-mobile-lang),
:host-context(.alt-mobile-controls) {
  .language-selector {
    width: auto;
    height: auto;
    flex-wrap: wrap;
    justify-content: center;
  }

  .language-dropdown,
  .currency-dropdown {
    position: static;
    opacity: 1;
    visibility: hidden;
    transform: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, visibility 0s 0.3s;
    box-shadow: none;
    border: none;
    border-radius: var(--radius-sm, 8px);
    margin-top: 8px;
    background: rgba(233, 237, 241, 0.9);

    &.open {
      visibility: visible;
      max-height: 200px;
      transition: max-height 0.3s ease, visibility 0s 0s;
    }
  }

  .language-option,
  .currency-option {
    color: #1e3c38;
    
    &:hover:not(.disabled) {
      background: rgba(161, 180, 181, 0.3);
    }

    &.active {
      background: rgba(73, 118, 113, 0.15);
    }
  }
}

// ── Currency selector ──
.language-selector {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.currency-button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm, 8px);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: var(--font-size-base, 0.875rem);
  font-weight: var(--font-weight-medium, 500);

  &:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
  }

  .currency-symbol {
    font-size: var(--font-size-md, 0.9375rem);
    font-weight: var(--font-weight-bold, 700);
  }

  .currency-code {
    font-size: var(--font-size-sm, 0.8125rem);
    letter-spacing: 0.5px;
  }

  .dropdown-arrow {
    transition: transform 0.3s ease;
    opacity: 0.7;
    &.rotated { transform: rotate(180deg); }
  }
}

.currency-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  background: var(--card-bg, #1a1a1a);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 1000;
  overflow: hidden;

  &.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

.currency-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: var(--font-size-base, 0.875rem);

  &:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  &.active {
    background: rgba(255, 255, 255, 0.1);
    font-weight: var(--font-weight-semibold, 600);
  }

  .cur-symbol {
    font-size: var(--font-size-lg, 1rem);
    font-weight: var(--font-weight-bold, 700);
    width: 20px;
    text-align: center;
  }

  .cur-name {
    flex: 1;
  }

  .cur-code {
    font-size: var(--font-size-xs, 0.75rem);
    opacity: 0.6;
  }
}

// Light / alt / platform theme adjustments for currency
:host-context(.alt-header),
:host-context(.header) {
  .currency-button {
    border-color: rgba(0, 0, 0, 0.2);
    color: #333333;
    &:hover {
      background: rgba(0, 0, 0, 0.05);
      border-color: rgba(0, 0, 0, 0.3);
    }
  }
}

:host-context(.light-theme) {
  .currency-dropdown {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  }
  .currency-option {
    color: #333333;
    &:hover { background: rgba(0, 0, 0, 0.05); }
    &.active { background: rgba(0, 0, 0, 0.1); }
  }
}

:host-context(.platform-header),
:host-context(.platform-mobile-menu) {
  .currency-button {
    padding: 4px 8px;
    gap: 3px;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid #677b78;
    border-radius: var(--radius-sm, 8px);
    color: #1e3c38;
    &:hover {
      background: rgba(255, 255, 255, 0.5);
    }
    .currency-symbol { font-size: var(--font-size-base, 0.875rem); color: #1e3c38; }
    .currency-code { font-size: var(--font-size-sm, 0.8125rem); color: #1e3c38; }
    .dropdown-arrow path { stroke: #1e3c38; }
  }
  .currency-dropdown {
    background: #ffffff;
    border-color: #d3dad9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  .currency-option {
    color: #1e3c38;
    &:hover { background: rgba(161, 180, 181, 0.2); }
    &.active { background: rgba(73, 118, 113, 0.1); }
  }
}


