/* ==========================================================
   RailPass — Custom Searchable Dropdown
   Replaces the raw browser <select> popup with a styled,
   searchable panel that matches the site's design system.
   ========================================================== */

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

.rp-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border-light);
  background: #eef2f9;
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-dark);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.rp-select-trigger:hover { background: #e7edf6; }
.rp-select-trigger .rp-select-value.placeholder { color: #98a3b3; }
.rp-select-trigger .rp-select-chevron {
  flex-shrink: 0;
  color: #5b6675;
  transition: transform .2s var(--ease);
}

.rp-select.open .rp-select-trigger {
  border-color: var(--orange);
  background: #fff;
}
.rp-select.open .rp-select-trigger .rp-select-chevron { transform: rotate(180deg); }

.rp-select.field-invalid .rp-select-trigger { border-color: #e23744; background: #fff5f5; }

.rp-select-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lift);
  z-index: 40;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.rp-select.open .rp-select-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.rp-select.dropup .rp-select-panel {
  top: auto;
  bottom: calc(100% + 8px);
  transform: translateY(6px);
}
.rp-select.dropup.open .rp-select-panel {
  transform: translateY(0);
}

.rp-select-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-muted);
}
.rp-select-search svg { flex-shrink: 0; }
.rp-select-search input {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-dark);
  width: 100%;
  background: transparent;
}
.rp-select-search input::placeholder { color: #98a3b3; }

.rp-select-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 232px;
  overflow-y: auto;
}
.rp-select-list::-webkit-scrollbar { width: 7px; }
.rp-select-list::-webkit-scrollbar-thumb { background: #dde3ec; border-radius: 999px; }
.rp-select-list::-webkit-scrollbar-track { background: transparent; }

.rp-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.rp-select-option:hover,
.rp-select-option.active { background: #FFF1E8; color: var(--orange-dark); }
.rp-select-option.selected { color: var(--orange); font-weight: 700; background: #FFF1E8; }
.rp-select-option .rp-check { margin-left: auto; flex-shrink: 0; opacity: 0; color: var(--orange); }
.rp-select-option.selected .rp-check { opacity: 1; }

.rp-select-empty {
  padding: 18px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Hide the native select once JS has enhanced it; it stays in the
   DOM (off-screen, not display:none) so form logic + a11y still work. */
.rp-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;
}

@media (max-width: 340px) {
  .rp-select-trigger { padding: 11px 12px; font-size: 13px; }
  .rp-select-search input { font-size: 12.5px; }
  .rp-select-option { padding: 8px 10px; font-size: 12.5px; }
  .rp-select-list { max-height: 180px; }
}

/* ==========================================================
   RTL FIX: Station dropdown must stay LTR for English names
   ========================================================== */
/* In RTL mode, keep the dropdown panel itself LTR */
html[dir="rtl"] .rp-select {
  direction: ltr;
  text-align: left;
}
/* Trigger value stays LTR for selected station name */
html[dir="rtl"] .rp-select-trigger,
html[dir="rtl"] .rp-select-value {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}
/* Dropdown panel: force LTR so English station names align left */
html[dir="rtl"] .rp-select-panel {
  direction: ltr;
  text-align: left;
  left: 0;
  right: auto;
}
/* Search input in dropdown: LTR */
html[dir="rtl"] .rp-select-search input {
  direction: ltr;
  text-align: left;
}
/* Station list items: LTR alignment */
html[dir="rtl"] .rp-select-list {
  direction: ltr;
  text-align: left;
}
/* Each option: LTR text */
html[dir="rtl"] .rp-select-option {
  direction: ltr;
  text-align: left;
  justify-content: flex-start;
}
/* Checkmark stays right in LTR context */
html[dir="rtl"] .rp-select-option .rp-check {
  margin-left: auto;
  margin-right: 0;
}
