/*
  Gabriel Airlines — custom form components (select + date picker)
  These replace the native <select>/<input type="date"> controls in the
  booking form. The native elements stay in the DOM (hidden) so the
  booking JS keeps reading their .value/.disabled/classList unchanged.
*/

/* ---------- shared trigger look ---------- */

.ui-select,
.ui-datepicker {
  position: relative;
  width: 100%;
}

.ui-select-trigger,
.ui-date-trigger {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-muted);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.ui-date-trigger {
  justify-content: flex-start;
}

.ui-select-trigger .ui-select-value,
.ui-date-trigger .ui-date-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.ui-select-trigger.has-value .ui-select-value,
.ui-date-trigger.has-value .ui-date-value {
  color: var(--text-primary);
}

.ui-select-trigger i {
  color: var(--text-muted);
  font-size: 0.85em;
  transition: transform var(--duration-fast) var(--ease-standard);
  flex-shrink: 0;
}

.ui-date-trigger i {
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.ui-select.is-open .ui-select-trigger,
.ui-select-trigger:hover,
.ui-datepicker.is-open .ui-date-trigger,
.ui-date-trigger:hover {
  border-color: var(--accent-cyan);
}

.ui-select.is-open .ui-select-trigger {
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.ui-select.is-open .ui-select-trigger i {
  transform: rotate(180deg);
}

.ui-select.has-error .ui-select-trigger,
.ui-datepicker.has-error .ui-date-trigger {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 84, 112, 0.15);
}

.ui-select.is-disabled,
.ui-datepicker.is-disabled {
  opacity: 0.45;
}

.ui-select.is-disabled .ui-select-trigger,
.ui-datepicker.is-disabled .ui-date-trigger {
  cursor: not-allowed;
}

/* ---------- select panel ---------- */

.ui-select-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: max(100%, 260px);
  max-height: 320px;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 50;
  overflow: hidden;
  animation: panel-in 0.15s var(--ease-standard);
}

/* Opacity-only on purpose: a `transform` keyframe here would fully replace
   whatever static `transform` the panel needs for its resting position
   (e.g. the mobile media query's translate(-50%,-50%) centering) for the
   animation's duration, then hand back control to the static value the
   instant it finishes - which reads as the panel jumping/snapping into
   place right after appearing. Each breakpoint that wants a fancier
   entrance redefines this same @keyframes ending at its own resting
   transform instead (see the mobile override below). */
@keyframes panel-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ui-select-search {
  margin: var(--space-2);
  width: auto;
}

.ui-select-list {
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.ui-select-group-label {
  padding: var(--space-2) var(--space-4) 4px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ui-select-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px var(--space-4);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.ui-select-option:hover {
  background: var(--glass-bg-strong);
  color: var(--text-primary);
}

.ui-select-option.is-selected {
  color: var(--accent-cyan);
  font-weight: 600;
}

.ui-select-option.is-selected::after {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  float: right;
}

.ui-select-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- date picker panel ---------- */

.ui-date-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 300px;
  padding: var(--space-4);
  background: var(--bg-elevated-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 50;
  animation: panel-in 0.15s var(--ease-standard);
}

.ui-date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.ui-date-month-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  text-transform: capitalize;
}

.ui-date-nav {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg-strong);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.ui-date-nav:hover {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
}

.ui-date-weekdays,
.ui-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.ui-date-weekdays span {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-bottom: var(--space-2);
}

.ui-date-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.ui-date-day:hover:not(:disabled) {
  background: var(--glass-bg-strong);
  color: var(--text-primary);
}

.ui-date-day.is-today {
  color: var(--accent-cyan);
  font-weight: 600;
}

.ui-date-day.is-selected {
  background: var(--accent-gradient);
  color: #04121a;
  font-weight: 700;
}

.ui-date-day:disabled {
  color: var(--text-muted);
  opacity: 0.35;
  cursor: not-allowed;
}

/* flip the panel above the trigger when there's no room below it */
.ui-select.opens-up .ui-select-panel,
.ui-datepicker.opens-up .ui-date-panel {
  top: auto;
  bottom: calc(100% + 8px);
}

@media only screen and (max-width: 600px) {
  /* On narrow screens, anchoring the panel below/above its own trigger
     risks it landing partly off-screen no matter which field opened it
     (Origem sits near the left edge, Passageiros near the right...). Fixed
     + centered on the viewport sidesteps that entirely - it always fits,
     regardless of which trigger opened it or how that trigger's own
     ancestors are positioned. */
  .ui-select-panel,
  .ui-date-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(88vw, 340px);
    max-height: min(70vh, 420px);
  }

  .ui-select.opens-up .ui-select-panel,
  .ui-datepicker.opens-up .ui-date-panel {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
  }

  /* Redefines the same @keyframes name so it ends at *this* breakpoint's
     resting transform (translate(-50%,-50%)) instead of `none` - a gentle
     scale/settle into the centered spot rather than a plain fade snapping
     into position right after. */
  @keyframes panel-in {
    from { opacity: 0; transform: translate(-50%, -46%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
  }
}
