/**
 * CPAF — Dropdown display type
 * Covers both the native <select> and the custom swatch dropdown.
 */

/* ── Native select ──────────────────────────────────────────────────────── */

.cpaf-native-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 4px;
  background: var(--wp--preset--color--surface);
  font-size: 0.95em;
  color: inherit;
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: auto;
}

.cpaf-native-select:focus {
  outline: 2px solid var(--cpaf-color-primary);
  outline-offset: 2px;
}

/* ── Custom select wrapper ──────────────────────────────────────────────── */

.cpaf-custom-select {
  position: relative;
  user-select: none;
}

/* Trigger */
.cpaf-custom-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 4px;
  background: var(--wp--preset--color--surface);
  font-size: 0.95em;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s;
  min-height: unset;
}

.cpaf-custom-select__trigger:hover,
.cpaf-custom-select--open .cpaf-custom-select__trigger {
  border-color: var(--cpaf-color-primary);
}

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

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

.cpaf-custom-select__arrow {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--wp--preset--color--text-light);
  transition: transform 0.2s ease;
}

.cpaf-custom-select--open .cpaf-custom-select__arrow {
  transform: rotate(180deg);
}

/* Dropdown panel */
.cpaf-custom-select__dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 999;
  background: var(--wp--preset--color--surface);
  border: 1px solid var(--wp--preset--color--border);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  max-height: 260px;
  overflow-y: auto;
}

.cpaf-custom-select__dropdown[hidden] {
  display: none;
}

/* Option row */
.cpaf-custom-select__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.95em;
  cursor: pointer;
  transition: background 0.1s;
}

.cpaf-custom-select__option:hover {
  background: var(--wp--preset--color--surface-alt);
}

.cpaf-custom-select__option:focus-visible {
  outline: none;
  background: var(--wp--preset--color--surface-alt);
}

.cpaf-custom-select__option--active {
  font-weight: 600;
  color: var(--cpaf-color-primary);
}

.cpaf-custom-select__option--active .cpaf-swatch {
  box-shadow: 0 0 0 2px var(--cpaf-color-primary);
}

.cpaf-custom-select__option--empty {
  opacity: 0.4;
  pointer-events: none;
}

.cpaf-custom-select__label {
  flex: 1;
}

/* Swatch in dropdown options — slightly larger */
.cpaf-custom-select__option .cpaf-swatch {
  width: 18px;
  height: 18px;
}

/* Divider after first "Any" option */
.cpaf-custom-select__option:first-child {
  border-bottom: 1px solid var(--wp--preset--color--border);
}

/* Scrollbar polish */
.cpaf-custom-select__dropdown::-webkit-scrollbar {
  width: 4px;
}
.cpaf-custom-select__dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.cpaf-custom-select__dropdown::-webkit-scrollbar-thumb {
  background: var(--wp--preset--color--border);
  border-radius: 2px;
}
