/**
 * nv-select — custom dropdown (DS chip trigger + floating menu)
 */

/*
 * Native form selects keep their platform semantics and inherit the product's
 * dark UI. The fully branded picker is intentionally limited to the dashboard
 * money drawers, whose controls share one DS geometry.
 */
body.dash-page select:not(.nv-select__native) {
  color-scheme: dark;
}

body.dash-page select:not(.nv-select__native) option,
body.dash-page select:not(.nv-select__native) optgroup {
  background: var(--dash-popover-bg, #222222);
  color: var(--dash-text, #eeeeee);
}

body.dash-page select:not(.nv-select__native) option:disabled {
  color: var(--dash-text-muted, #8f8f8f);
}

body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select {
  appearance: none;
  padding-inline-end: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23a2a2a2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: calc(100% - var(--control-padding-x, 14px)) center;
  background-repeat: no-repeat;
  background-size: 12px 8px;
}

@supports (appearance: base-select) {
  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select,
  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select::picker(select) {
    appearance: base-select;
  }

  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select {
    padding-inline-end: var(--control-padding-x, 14px);
    background-image: none;
  }

  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select::picker(select) {
    margin-block-start: 6px;
    padding: 6px;
    border: 1px solid var(--dash-border-strong, rgba(255, 255, 255, 0.14));
    border-radius: 14px;
    background: var(--dash-popover-bg, #222222);
    color: var(--dash-text, #eeeeee);
    box-shadow: var(--dash-popover-shadow, 0 16px 48px rgba(0, 0, 0, 0.45));
  }

  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select option {
    min-height: 40px;
    padding: 10px 36px 10px 14px;
    border-radius: 10px;
    background: transparent;
    color: var(--dash-text, #eeeeee);
  }

  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select option:hover,
  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select option:focus-visible,
  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select option:checked {
    background: var(--dash-popover-row-bg, rgba(255, 255, 255, 0.06));
    color: var(--dash-text, #eeeeee);
  }

  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select::picker-icon {
    content: '';
    inline-size: 12px;
    block-size: 8px;
    margin-inline-start: var(--spacing-sm, 8px);
    background: currentColor;
    color: var(--dash-text-muted, #a2a2a2);
    opacity: 0.65;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transition:
      transform var(--transition-fast, 150ms) ease,
      opacity var(--transition-fast, 150ms) ease;
  }

  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select:hover::picker-icon {
    opacity: 1;
  }

  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select:open::picker-icon {
    transform: rotate(180deg);
  }

  body.dash-page :is(.csend-drawer__field, .cdep-drawer__field) select option::checkmark {
    content: '';
    inline-size: 14px;
    block-size: 14px;
    background: currentColor;
    color: var(--dash-text-muted, #a2a2a2);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / contain no-repeat;
  }
}

.nv-select-wrap {
  position: relative;
  display: inline-flex;
  width: auto;
  flex-shrink: 0;
}

.nv-select-wrap--chip {
  --nv-select-height: 32px;
}

select.nv-select__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nv-select__trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--nv-select-height, var(--control-height-md, 41px));
  padding: 0 32px 0 14px;
  border: none;
  border-radius: 999px;
  background: var(--dash-surface);
  color: var(--dash-text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dash-transition), color var(--dash-transition);
}

.nv-select__trigger:hover {
  background: var(--dash-surface-hover);
  color: var(--dash-text);
}

.nv-select-wrap.is-open .nv-select__trigger {
  background: var(--dash-surface-hover);
  color: var(--dash-text);
}

.nv-select__trigger:focus-visible {
  outline: 2px solid var(--dash-accent-focus);
  outline-offset: 2px;
}

.nv-select__chev {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  opacity: 0.5;
  pointer-events: none;
  transition: transform 150ms ease, opacity 150ms ease;
}

.nv-select-wrap.is-open .nv-select__chev {
  transform: translateY(-50%) rotate(180deg);
  opacity: 0.85;
}

.nv-select__chev svg {
  display: block;
  width: 14px;
  height: 14px;
}

.nv-select__menu {
  position: fixed;
  z-index: var(--dash-popover-z, 1600);
  min-width: 180px;
  max-height: min(52vh, 340px);
  padding: 6px;
  margin: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--dash-popover-bg, #222222);
  box-shadow: var(--dash-popover-shadow, 0 16px 48px rgba(0, 0, 0, 0.45));
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 150ms ease, visibility 150ms ease;
}

/* Menu may live in body when open — do not rely on .nv-select-wrap ancestor */
.nv-select__menu:not([hidden]),
.nv-select__menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.nv-select__menu-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(52vh, 328px);
  overflow-y: auto;
  background: var(--dash-popover-bg, #222222);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.nv-select__option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: var(--dropdown-option-padding-y, 10px) var(--dropdown-option-padding-x, 14px);
  padding-right: var(--dropdown-option-selected-padding-right, 36px);
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--dash-text);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background 150ms ease;
}

.nv-select__option:hover,
.nv-select__option.is-focused {
  background: rgba(255, 255, 255, 0.06);
}

.nv-select__option.is-selected {
  background: rgba(255, 255, 255, 0.06);
}

.nv-select__option.is-selected::after {
  content: '';
  position: absolute;
  right: var(--dropdown-check-right, 14px);
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

.nv-select__menu:not([hidden]) .nv-select__option.is-selected,
.nv-select__menu.is-open .nv-select__option.is-selected {
  display: none;
}
