/* ============================================================
   BRUNCH & BUILD — UNBRANDED EDITORIAL CUSTOM SELECT + FILTER
   Enhances all .select-wrap > select controls across forms.
   Automatically displays a top keyword filter when options > 5.
   ============================================================ */

.form-row.has-open-select,
.form-row:has(.select-wrap.is-open) {
  position: relative;
  z-index: 80;
}

.select-wrap.cselect-enhanced {
  position: relative;
}

.select-wrap.cselect-enhanced.is-open {
  z-index: 80;
}

/* Keep native <select> in DOM for FormData + HTML5 required validation,
   visually hidden behind the custom trigger so OS/browser menus never open. */
.select-wrap.cselect-enhanced > select {
  position: absolute !important;
  left: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 1px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide legacy static chevron icon once custom trigger renders its animated chevron */
.select-wrap.cselect-enhanced > .icon,
.select-wrap.cselect-enhanced > svg.lucide {
  display: none !important;
}

/* Custom Select Trigger */
.cselect-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 51px;
  padding: 0 16px;
  border: 1px solid var(--slate-2, #27223F);
  border-radius: 0;
  background: #171428;
  color: var(--white, #F7F5FC);
  font-family: var(--font-sans, 'Figtree', sans-serif);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  user-select: none;
  outline: none;
  transition:
    border-color .22s ease,
    background-color .22s ease,
    box-shadow .22s ease;
}

.cselect-trigger:hover {
  border-color: rgba(247, 245, 252, .22);
  background: #1A162E;
}

.cselect-trigger:focus-visible,
.select-wrap.is-open .cselect-trigger {
  border-color: var(--coral, #FF6846);
  background: #1E1A33;
}

.select-wrap.is-invalid .cselect-trigger {
  border-color: var(--coral, #FF6846);
  box-shadow: 0 0 0 1px rgba(255, 104, 70, .28);
}

.cselect-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-wrap.is-placeholder .cselect-label {
  color: #777092;
}

.cselect-chevron {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  color: var(--coral, #FF6846);
  transition: transform .3s cubic-bezier(.22, 1, .36, 1), color .22s ease;
}

.cselect-chevron svg {
  width: 17px;
  height: 17px;
  display: block;
}

.select-wrap.is-open .cselect-chevron {
  transform: rotate(180deg);
}

/* Dropdown Popover Panel */
.cselect-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 90;
  background: #131022;
  border: 1px solid rgba(247, 245, 252, .14);
  box-shadow:
    0 24px 56px rgba(5, 4, 12, .82),
    0 0 0 1px rgba(13, 11, 22, .92);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transform-origin: top center;
  transition:
    opacity .2s ease,
    transform .24s cubic-bezier(.22, 1, .36, 1),
    visibility 0s linear .24s;
}

.select-wrap.is-dropup .cselect-menu {
  top: auto;
  bottom: calc(100% + 6px);
  transform: translateY(6px);
  transform-origin: bottom center;
}

.select-wrap.is-open .cselect-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition:
    opacity .2s ease,
    transform .24s cubic-bezier(.22, 1, .36, 1),
    visibility 0s linear 0s;
}

/* Keyword Search Bar (automatically added when selectable options > 5) */
.cselect-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(247, 245, 252, .09);
  background: #17132A;
}

.cselect-search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: #8E87AA;
  pointer-events: none;
  display: inline-flex;
}

.cselect-search-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* Override generic .form-row input rules cleanly */
.form-row .cselect-search,
.cselect-search {
  width: 100% !important;
  height: 38px !important;
  padding: 0 32px 0 34px !important;
  border: 1px solid rgba(247, 245, 252, .11) !important;
  border-radius: 0 !important;
  background: #100D1D !important;
  color: var(--white, #F7F5FC) !important;
  font-family: var(--font-sans, 'Figtree', sans-serif) !important;
  font-size: 13px !important;
  line-height: 1.2 !important;
  outline: none !important;
  transition: border-color .2s ease, background-color .2s ease !important;
}

.form-row .cselect-search::placeholder,
.cselect-search::placeholder {
  color: #777092 !important;
}

.form-row .cselect-search:focus,
.cselect-search:focus {
  border-color: rgba(255, 104, 70, .65) !important;
  background: #151126 !important;
}

.cselect-search-clear {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #9A93B5;
  cursor: pointer;
  transition: color .18s ease;
}

.cselect-search-clear.is-visible {
  display: inline-flex;
}

.cselect-search-clear:hover {
  color: var(--white, #F7F5FC);
}

.cselect-search-clear svg {
  width: 13px;
  height: 13px;
  display: block;
}

/* Scrollable Option List */
.cselect-list {
  margin: 0;
  padding: 6px 0;
  list-style: none;
  max-height: 244px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(247, 245, 252, .18) transparent;
}

.cselect-list::-webkit-scrollbar {
  width: 6px;
}

.cselect-list::-webkit-scrollbar-track {
  background: transparent;
}

.cselect-list::-webkit-scrollbar-thumb {
  background: rgba(247, 245, 252, .18);
}

.cselect-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  color: rgba(247, 245, 252, .84);
  font-family: var(--font-sans, 'Figtree', sans-serif);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s ease, color .15s ease;
}

.cselect-option[hidden] {
  display: none !important;
}

.cselect-option.is-highlighted {
  background: rgba(247, 245, 252, .06);
  color: var(--white, #F7F5FC);
}

.cselect-option.is-selected {
  background: rgba(255, 104, 70, .1);
  color: var(--white, #F7F5FC);
  font-weight: 600;
}

.cselect-option.is-selected.is-highlighted {
  background: rgba(255, 104, 70, .16);
}

.cselect-option-text {
  flex: 1 1 auto;
  min-width: 0;
}

.cselect-check {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  color: var(--coral, #FF6846);
  opacity: 0;
  transform: scale(.85);
  transition: opacity .16s ease, transform .18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cselect-option.is-selected .cselect-check {
  opacity: 1;
  transform: scale(1);
}

.cselect-check svg {
  width: 15px;
  height: 15px;
  display: block;
}

.cselect-empty {
  padding: 16px;
  color: #8A83A6;
  font-family: var(--font-sans, 'Figtree', sans-serif);
  font-size: 13px;
  text-align: center;
}

.cselect-empty[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .cselect-menu,
  .cselect-chevron,
  .cselect-option,
  .cselect-check {
    transition: none !important;
  }
}
