/**
 * TravelExpense — progressive enhancement for native <select class="te-custom-select">.
 * Visual language aligns with Bootstrap form-select + design tokens (portal.css).
 */

.te-custom-select-root {
  position: relative;
  width: 100%;
  max-width: 100%;
}

select.te-custom-select-native-src {
  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;
}

.te-custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  min-height: calc(1.5em + 0.75rem + 2px);
  text-align: left;
  cursor: pointer;
  background-color: var(--color-bg-card, #fff);
  color: var(--color-text-primary, #1e1e1e);
}

.te-custom-select-trigger:disabled,
.te-custom-select-trigger.te-custom-select-trigger--disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.te-custom-select-trigger > .te-custom-select-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.te-custom-select-trigger > .te-custom-select-chevron {
  flex-shrink: 0;
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0.65;
  transition: transform 0.15s ease;
}

.te-custom-select-trigger[aria-expanded="true"] > .te-custom-select-chevron {
  transform: rotate(180deg);
}

.te-custom-select-trigger:focus-visible {
  border-color: var(--color-accent-strong, #b1cc74);
  box-shadow: 0 0 0 0.2rem rgba(177, 204, 116, 0.35);
  outline: 0;
}

.te-custom-select-trigger.is-invalid {
  border-color: var(--bs-form-invalid-border-color, #dc3545);
}

.te-custom-select-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
  background: rgba(0, 0, 0, 0.45);
}

.te-custom-select-overlay.te-custom-select-overlay--open {
  display: block;
}

.te-custom-select-panel {
  position: fixed;
  z-index: 1090;
  display: none;
  flex-direction: column;
  max-height: min(70vh, 560px);
  background: var(--color-bg-card, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.te-custom-select-panel.te-custom-select-panel--open {
  display: flex;
}

.te-custom-select-panel--sheet {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 70vh;
  border-radius: 0.5rem 0.5rem 0 0;
  border-bottom: none;
  animation: te-csel-sheet-in 0.22s ease-out;
}

@keyframes te-csel-sheet-in {
  from {
    transform: translateY(12px);
    opacity: 0.85;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.te-custom-select-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border, #e0e0e0);
  background: var(--color-bg-card, #fff);
  flex-shrink: 0;
}

.te-custom-select-panel-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-secondary, #545f66);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.te-custom-select-panel-close {
  border: 0;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  color: var(--color-text-secondary, #545f66);
}

.te-custom-select-search {
  width: 100%;
  margin-bottom: 0;
}

.te-custom-select-options {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0;
}

.te-custom-select-option {
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--color-text-primary, #1e1e1e);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  display: block;
}

.te-custom-select-option:hover,
.te-custom-select-option:focus-visible {
  background: rgba(177, 204, 116, 0.18);
  outline: 0;
}

.te-custom-select-option[aria-selected="true"] {
  background: rgba(177, 204, 116, 0.28);
  font-weight: 600;
}

.te-custom-select-option.te-custom-select-option--highlight {
  outline: 2px solid var(--color-accent-strong, #b1cc74);
  outline-offset: -2px;
}

.te-custom-select-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.modal .te-custom-select-overlay {
  z-index: 2000;
}

.modal .te-custom-select-panel {
  z-index: 2010;
}
