/**
 * BLAZEBYTE STUDIO — ACCESSIBLE CUSTOM SELECT / COMBOBOX
 * Dark purple/navy theme with restrained cyan border and glow.
 * Eliminates OS native select popup white artifacts, label clipping, and hover glitches.
 */

/* Container wrapper */
.custom-select-wrapper {
  position: relative;
  width: 100%;
  font-family: var(--font-body);
  user-select: none;
}

/* Visually hidden native select — keeps full accessibility, validation & FormData */
.visually-hidden-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Custom Combobox Trigger Button */
.custom-select-trigger {
  width: 100%;
  min-height: 48px;
  background: rgba(13, 10, 31, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  box-sizing: border-box;
}

.custom-select-trigger:hover {
  border-color: rgba(0, 245, 255, 0.4);
  background: rgba(18, 14, 42, 0.95);
}

.custom-select-trigger:focus,
.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--cyan);
  box-shadow: 0 0 14px var(--cyan-glow);
  background: rgba(18, 14, 42, 0.98);
}

.custom-select-trigger.has-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.35) !important;
}

/* Trigger Value Text */
.custom-select-value {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f8fafc;
}

.custom-select-trigger.is-placeholder .custom-select-value {
  color: var(--text-muted);
}

/* Trigger Chevron Arrow */
.custom-select-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.custom-select-wrapper.open .custom-select-arrow {
  transform: rotate(180deg);
}

/* Dropdown Menu (Listbox) */
.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  width: 100%;
  max-height: 290px;
  background: #080c22;
  border: 1px solid rgba(0, 245, 255, 0.35);
  border-radius: 10px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.85), 0 0 20px rgba(0, 245, 255, 0.12);
  padding: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  box-sizing: border-box;
}

/* Open upwards if near viewport bottom */
.custom-select-wrapper.open-up .custom-select-menu {
  top: auto;
  bottom: calc(100% + 6px);
  transform: translateY(6px);
}

.custom-select-wrapper.open .custom-select-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* Scrollbar Customization — Zero White Areas */
.custom-select-menu::-webkit-scrollbar {
  width: 6px;
}
.custom-select-menu::-webkit-scrollbar-track {
  background: #050817;
  border-radius: 4px;
}
.custom-select-menu::-webkit-scrollbar-thumb {
  background: rgba(0, 245, 255, 0.3);
  border-radius: 4px;
}
.custom-select-menu::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
}
.custom-select-menu {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 245, 255, 0.3) #050817;
}

/* Options Container */
.custom-select-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Option Row */
.custom-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  word-break: break-word;
  white-space: normal;
  box-sizing: border-box;
}

/* Hover State — Smooth subtle neon wash, NEVER changes selected value */
.custom-select-option:hover {
  background: rgba(0, 245, 255, 0.08);
  color: #ffffff;
}

/* Keyboard-focused State (Arrow navigation / activedescendant) */
.custom-select-option.is-focused {
  background: rgba(0, 245, 255, 0.12);
  color: var(--cyan);
  outline: 1px solid rgba(0, 245, 255, 0.45);
  outline-offset: -1px;
}

/* Selected State */
.custom-select-option.selected,
.custom-select-option[aria-selected="true"] {
  background: rgba(0, 245, 255, 0.16);
  color: var(--cyan);
  font-weight: 600;
}

.custom-select-option.selected.is-focused {
  background: rgba(0, 245, 255, 0.22);
}

/* Option Label */
.option-label {
  flex: 1;
}

/* Option Checkmark */
.option-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--cyan);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.custom-select-option.selected .option-check,
.custom-select-option[aria-selected="true"] .option-check {
  opacity: 1;
  transform: scale(1);
}

/* Form Group Stacking Context Fix */
.form-group.has-custom-select {
  position: relative;
  overflow: visible;
  z-index: 1;
}

.form-group.has-custom-select.custom-select-open {
  z-index: 1000;
}

/* Form grid overflow fix */
.form-grid {
  overflow: visible !important;
}

/* Mobile responsive handling */
@media (max-width: 640px) {
  .custom-select-trigger {
    padding: 12px 14px;
    font-size: 14px;
  }
  .custom-select-menu {
    max-height: 250px;
  }
  .custom-select-option {
    padding: 10px 12px;
    font-size: 13.5px;
  }
}
