﻿@import url('../../css-variables.css');

.selector {
  grid-area: selector;
  border: 1px solid var(--border-neutral-default);
  border-radius: 4px;
  width: fit-content;   /* Let it size to content */
  min-width: 150px;     /* Minimum width */
  max-width: 300px;     /* Maximum before truncating */
  position: relative;
  font-family: var(--font-family-brand);
  font-weight: 400;
  font-size: var(--font-size-html);
  line-height: 20px;
}

/* The button that acts as the dropdown toggle */
.dropdown-toggle {
  width: 100%;
  padding: 10px;
  background-color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  white-space: nowrap;      /* Keep text on one line */
  overflow: hidden;         /* Hide overflow */
  text-overflow: ellipsis;  /* Show ... when text overflows */
}

.dropdown-toggle:focus {
  outline: none;
}

/* Ensure the text inside toggle button truncates properly */
.dropdown-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 24px;  /* Space for the arrow */
}

/* The dropdown menu itself */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: auto;          /* Changed from 100% */
  min-width: 100%;      /* Added */
  max-width: 300px;     /* Added */
  background-color: white;
  border: 1px solid var(--border-neutral-default);
  border-radius: 4px;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
  list-style: none;
  padding: 4px;
  margin: 0;
  display: none;
  z-index: 10;
}

.dropdown-menu li {
  border: none; /* Remove borders between items */
  margin: 0;
  padding: 0;
}

/* Ensure menu items wrap properly */
.dropdown-menu a {
  white-space: normal;    /* Added - allow wrapping */
  word-break: break-word; /* Added - prevent overflow */
  line-height: 1.2;      /* Added - tighter line height for wrapped text */
  display: block;
  padding: 12px;
  text-decoration: none !important;
  color: var(--text-neutral-default) !important;
  width: 100%;
  box-sizing: border-box;
  transition: background-color 0.2s ease;
  border-radius: 4px; /* Add border radius to highlight */
}

.dropdown-menu a:hover {
  background-color: var(--background-neutral-strong);
}

.dropdown-menu a:focus,
.dropdown-menu a.active {
  color: var(--text-brand-default);
  background-color: var(--background-neutral-strong);
}

.dropdown-arrow {
    transition: transform 0.3s ease;
    display: inline-block;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

/*Dark theme adjustments*/
:root[data-theme="dark"] .dropdown-menu a {
  color: var(--text-brand-default) !important;
}

:root[data-theme="dark"] .dropdown-menu,
:root[data-theme="dark"] .dropdown-toggle
{
   background-color: var(--background-nav1);
   color: var(--text-brand-default) !important;
}


:root[data-theme="dark"] .dropdown-menu a:focus,
:root[data-theme="dark"] .dropdown-menu a.active,
:root[data-theme="dark"] .dropdown-menu a:hover {

  background-color: var(--background-site);
}