/* ============================================
   Eventio Design System v3.3: DesignSelect
   Branded dropdown (Components/DesignSystem/DesignSelect.razor + js/design-select.js).
   Loaded right after tokens.css on purpose: a caller's own class (Tailwind utilities, .ew-input,
   .roi-select...) is defined later and wins ties, so the trigger keeps each screen's input look.
   ============================================ */

/* The wrapper takes no box, so the trigger is the flex/grid item a native select used to be. */
.ds-select { display: contents; }

/* ---- Trigger: structure only, so caller classes control the box ---- */
.ds-select__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-align: left;
  text-transform: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ds-select__trigger:disabled { cursor: not-allowed; opacity: 0.6; }
/* globals.css paints every button:focus-visible blue with !important; dropdowns use ink. */
.ds-select__trigger:focus-visible {
  outline: 2px solid var(--grey-900) !important;
  outline-offset: 2px !important;
}

.ds-select__label { display: grid; flex: 1 1 auto; min-width: 0; }
.ds-select__label > * {
  grid-area: 1 / 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ds-select__sizer { visibility: hidden; pointer-events: none; }
.ds-select__text.is-placeholder { color: var(--n-400); }

.ds-select__chevron {
  flex: none;
  width: 1em;
  min-width: 14px;
  height: 1em;
  min-height: 14px;
  color: var(--n-400);
  transition: transform 150ms ease;
}
.ds-select__trigger[aria-expanded="true"] .ds-select__chevron { transform: rotate(180deg); }

/* ---- Trigger: branded default look (no caller class/style, or an explicit Size) ---- */
.ds-select__trigger--default {
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--n-200);
  border-radius: var(--radius-md);
  background: var(--n-0);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--n-950);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.ds-select__trigger--default:hover:not(:disabled) { border-color: var(--n-300); }
.ds-select__trigger--default[aria-expanded="true"] { border-color: var(--grey-900); }
.ds-select__trigger--default:disabled { background: var(--n-100); color: var(--n-400); opacity: 1; }
.ds-select__trigger--sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: var(--radius-sm); }
.ds-select__trigger--lg { height: 48px; padding: 0 14px; font-size: 15px; }
.ds-select__trigger--default.invalid { border-color: var(--semantic-danger); }

/* ---- Popup: top layer via [popover]; fixed fallback where popover is unsupported ---- */
.ds-select__popup {
  position: fixed;
  inset: auto;
  top: 0;
  left: 0;
  z-index: 10000;
  margin: 0;
  padding: 4px;
  box-sizing: border-box;
  display: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: 320px;
  background: var(--n-0);
  color: var(--grey-900);
  border: 1px solid var(--n-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
}
.ds-select__popup[data-open] { display: block; }
.ds-select__popup[data-open]:popover-open { animation: ds-select-in 120ms ease-out; }
.ds-select__popup[data-placement="top"]:popover-open { animation-name: ds-select-in-up; }

.ds-select__list { outline: none; }
.ds-select__list:empty::after {
  content: "No options";
  display: block;
  padding: 8px 10px;
  color: var(--n-400);
}

.ds-select__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 7px 10px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  color: var(--n-700);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.ds-select__option-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.ds-select__check { flex: none; color: var(--grey-900); visibility: hidden; }
.ds-select__option[data-active] { background: var(--n-100); color: var(--grey-900); }
.ds-select__option[aria-selected="true"] { color: var(--grey-900); font-weight: 600; }
.ds-select__option[aria-selected="true"] .ds-select__check { visibility: visible; }
.ds-select__option[aria-disabled="true"] { color: var(--n-400); cursor: not-allowed; }
.ds-select__option[aria-disabled="true"][data-active] { background: transparent; }

.ds-select__group + .ds-select__group,
.ds-select__option + .ds-select__group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--n-100); }
.ds-select__group-label {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--n-500);
}

/* Touch screens: finger-sized rows. */
@media (pointer: coarse) {
  .ds-select__option { min-height: 44px; }
  .ds-select__popup { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-select__popup[data-open]:popover-open { animation: none; }
  .ds-select__chevron { transition: none; }
}

@keyframes ds-select-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes ds-select-in-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
