/* ==========================================================================
   Custom Select Dropdown – The Break Estate
   ==========================================================================
   Replaces the native <select> with a styled dropdown.
   The hidden native select stays in the DOM for form submission.
   ========================================================================== */

.tbe-select {
  position: relative;
  width: 100%;
}

.tbe-select > select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
/* Hide the native select immediately — before JS runs and wraps it */
select[data-tbe-select] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden;
}

.tbe-select > select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
/* --- Trigger --- */

.tbe-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--input-padding-y) var(--input-padding-x);
  font-family: var(--font-body);
  font-size: var(--input-font-size);
  line-height: var(--leading-normal);
  color: var(--input-color);
  background: var(--input-bg);
  border: var(--input-border-width) solid var(--input-border-color);
  border-radius: var(--input-radius);
  cursor: pointer;
  transition:
    background-color var(--transition-base),
    border-color var(--transition-base);
  text-align: left;
  -webkit-user-select: none;
  user-select: none;
}

.tbe-select-trigger:hover {
  border-color: var(--color-border-hover);
}

.tbe-select.is-open .tbe-select-trigger,
.tbe-select-trigger:focus {
  border-color: var(--color-border-focus);
  background: var(--input-bg-focus);
  outline: none;
}

/* Placeholder state */
.tbe-select-trigger[data-placeholder="true"] {
  color: var(--color-text-muted);
}

/* Caret */
.tbe-select-caret {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin-left: var(--space-sm);
  opacity: 0.4;
  transition:
    transform var(--transition-base),
    opacity var(--transition-base);
}

.tbe-select-caret svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tbe-select:hover .tbe-select-caret {
  opacity: 0.7;
}

.tbe-select.is-open .tbe-select-caret {
  transform: rotate(180deg);
  opacity: 0.8;
}

/* --- Dropdown panel --- */

.tbe-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-dropdown, 100);
  background: #130a0d;
  border: 1px solid rgba(228, 222, 212, 0.12);
  border-radius: var(--input-radius);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height var(--transition-base),
    opacity var(--transition-fast);
  pointer-events: none;
}

.tbe-select.is-open .tbe-select-dropdown {
  max-height: 16rem;
  overflow-y: auto;
  opacity: 1;
  pointer-events: auto;
}

/* Scrollbar */
.tbe-select-dropdown::-webkit-scrollbar {
  width: 4px;
}

.tbe-select-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.tbe-select-dropdown::-webkit-scrollbar-thumb {
  background: rgba(228, 222, 212, 0.15);
  border-radius: 2px;
}

/* --- Options --- */

.tbe-select-option {
  padding: var(--input-padding-y) var(--input-padding-x);
  font-family: var(--font-body);
  font-size: var(--input-font-size);
  color: var(--color-text);
  cursor: pointer;
  transition:
    background-color 150ms ease,
    color 150ms ease;
    text-align: left
}

.tbe-select-option:hover,
.tbe-select-option.is-focused {
  background: rgba(228, 222, 212, 0.06);
}

.tbe-select-option.is-selected {
  background: rgba(228, 222, 212, 0.1);
}

.tbe-select-option[data-disabled="true"] {
  color: var(--color-text-muted);
  cursor: default;
  pointer-events: none;
}

/* ---------- Touch device enhancements ---------- */

@media (pointer: coarse) {
  .tbe-select-trigger {
    min-height: 44px;
    font-size: 16px;
  }

  .tbe-select-option {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 16px;
  }

  .tbe-select-dropdown {
    -webkit-overflow-scrolling: touch;
  }
}
