/* === custom-select.css === */
/* Кастомний listbox поверх <select> (static/js/modules/custom-select.js).
   Нативний select лишається в DOM (для форми/htmx), але візуально прихований —
   попап опцій рендерить ОС і не піддається стилізації (особливо iOS Safari). */

.custom-select {
  position: relative;
  z-index: 1;
}

.custom-select.is-open {
  z-index: 50;
}

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

.custom-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: var(--text-body);
}

.custom-select__trigger:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.custom-select.is-open .custom-select__trigger {
  border-color: var(--color-accent);
}

.custom-select__value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select__chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}

.custom-select.is-open .custom-select__chevron {
  transform: rotate(180deg);
  color: var(--color-accent);
}

.custom-select__list {
  position: absolute;
  z-index: 50;
  top: calc(100% + var(--space-xs));
  left: 0;
  right: 0;
  max-height: min(320px, 60vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: var(--space-xs) 0;
  list-style: none;
  background-color: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-elevated);
}

.custom-select--upward .custom-select__list {
  top: auto;
  bottom: calc(100% + var(--space-xs));
}

.custom-select__option {
  display: flex;
  align-items: center;
  min-height: var(--touch-target);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-primary);
  font-size: var(--text-body);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.custom-select__option.is-active {
  background-color: var(--color-bg-panel);
}

.custom-select__option.is-selected {
  color: var(--color-accent);
  font-weight: 500;
}
