/**
 * Shared custom dropdown (custom-select.js).
 *
 * Replaces the native <select> popup with an on-brand, keyboard-accessible
 * listbox. The native <select> is kept in the DOM (hidden) as the value source.
 * Theme per context by overriding the --cs-* variables; the defaults below match
 * the dark apply-form design language.
 */

.cs {
  position: relative;
  width: 100%;
}

/* The enhanced native <select> is hidden but stays in the DOM for its value. */
.cs-native-hidden {
  display: none !important;
}

/* --- Trigger (looks like the field's original select) --- */
.cs-trigger {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 44px 0 18px;
  font-family: var(--cs-font, var(--font-body, 'helvetica-w01-roman', sans-serif));
  font-size: 15px;
  line-height: 21px;
  text-align: left;
  color: var(--cs-text, #ffffff);
  background: transparent;
  border: 0;
  border-bottom: 2.13333px solid var(--cs-border, #ffffff);
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cs-trigger.is-placeholder {
  color: var(--cs-placeholder, #c7c7c7);
}
.cs-trigger[aria-disabled="true"] {
  color: rgb(212, 212, 212);
  border-bottom-color: rgb(204, 204, 204);
  cursor: not-allowed;
}
.cs-trigger[aria-invalid="true"] {
  border-bottom-color: var(--cs-error, #FF4040);
}
.cs-trigger:focus-visible {
  outline: none;
  border-bottom-color: var(--cs-accent, rgb(189, 81, 23));
  box-shadow: 0 2px 0 0 var(--cs-accent, rgb(189, 81, 23));
}

.cs-label {
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cs-chevron {
  position: absolute;
  right: 18px;
  top: 50%;
  width: 12px;
  height: 7px;
  transform: translateY(-50%);
  transition: transform 0.2s ease;
  fill: var(--cs-chevron, #ffffff);
  pointer-events: none;
}
.cs-trigger[aria-expanded="true"] .cs-chevron {
  transform: translateY(-50%) rotate(180deg);
}

/* --- Panel (listbox) --- */
.cs-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: 264px;
  overflow-y: auto;
  background: var(--cs-panel-bg, #1b1b1f);
  border: 1px solid var(--cs-panel-border, rgba(255, 255, 255, 0.15));
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  -webkit-overflow-scrolling: touch;
}
.cs-panel[hidden] {
  display: none;
}
.cs[data-open="true"] .cs-panel {
  animation: cs-fade-in 0.12s ease;
}
@keyframes cs-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.cs-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  font-family: var(--cs-font, var(--font-body, 'helvetica-w01-roman', sans-serif));
  font-size: 15px;
  line-height: 20px;
  color: var(--cs-text, #ffffff);
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
}
.cs-option-text {
  flex: 1 1 auto;
}
.cs-option[aria-selected="true"] {
  color: var(--cs-selected, #F9843E);
}
/* Keyboard-active (aria-activedescendant) and pointer hover share one highlight. */
.cs-option.is-active,
.cs-option:hover {
  background: var(--cs-option-hover-bg, rgb(189, 81, 23));
  color: #ffffff;
}
.cs-check {
  flex: none;
  width: 16px;
  height: 16px;
  opacity: 0;
  fill: currentColor;
}
.cs-option[aria-selected="true"] .cs-check {
  opacity: 1;
}

/* --- Touch / small screens: larger tap targets, 16px text (no zoom) --- */
@media (max-width: 768px) {
  .cs-trigger { font-size: 16px; }
  .cs-option { font-size: 16px; min-height: 44px; }
  .cs-panel { max-height: 50vh; }
}
