/*
 * RideXpress Design System — Components v1
 *
 * Core reusable primitives, built entirely from tokens.css custom
 * properties. Namespaced `rx-*` throughout so these can be dropped
 * into any existing template (public site's Bootstrap+jQuery pages,
 * or the Material-Dashboard-based staff portals) without colliding
 * with either existing class system.
 *
 * Load order: tokens.css, then this file.
 *
 * v1 scope: Button, Badge, Alert, Card, Form Field, Table, Avatar,
 * Nav Item, Modal shell. Extend this file for new primitives — do not
 * start a second component system; see docs/engineering/FOUNDATION_COMPLETION_REPORT.md
 * for why duplicated implementations are the thing this codebase can
 * least afford to reaccumulate.
 *
 * v2 additions: Pagination, Tabs, Toast/Notification, Empty State,
 * Skeleton Loader, Dropdown Menu, Breadcrumb. Same rule as above —
 * every value below reads a tokens.css custom property unless a
 * comment says otherwise (a couple of one-off rgba() values follow
 * the precedent already set by .rx-modal-backdrop, where no token
 * exists for a translucent overlay tint).
 */

.rx-reset, .rx-reset * { box-sizing: border-box; }

/* Alpine.js: hide [x-cloak] elements until Alpine has initialized, so
   dropdown/modal/mobile-nav panels don't flash visible on page load
   before x-show evaluates. Required companion rule -- Alpine's own docs
   call this out as needed, not optional. */
[x-cloak] { display: none !important; }

/* ============================== Button ============================== */
.rx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rx-space-2);
  font-family: var(--rx-font-body);
  font-weight: var(--rx-weight-semibold);
  font-size: var(--rx-text-sm);
  line-height: 1;
  padding: 11px 20px;
  border-radius: var(--rx-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--rx-motion-instant) var(--rx-ease-standard),
              color var(--rx-motion-instant) var(--rx-ease-standard),
              border-color var(--rx-motion-instant) var(--rx-ease-standard);
  text-decoration: none;
  white-space: nowrap;
}
.rx-btn:disabled, .rx-btn.is-disabled { opacity: 0.5; cursor: not-allowed; }

.rx-btn--primary { background: var(--rx-color-brand); color: var(--rx-color-ink); }
.rx-btn--primary:hover:not(:disabled) { background: var(--rx-color-brand-strong); color: var(--rx-color-white); }

.rx-btn--dark { background: var(--rx-color-ink); color: var(--rx-color-text-on-dark); }
.rx-btn--dark:hover:not(:disabled) { background: var(--rx-color-ink-soft); }

.rx-btn--outline { background: transparent; border-color: var(--rx-color-border); color: var(--rx-color-text); }
.rx-btn--outline:hover:not(:disabled) { border-color: var(--rx-color-brand); color: var(--rx-color-brand-strong); }

.rx-btn--danger { background: var(--rx-color-danger); color: var(--rx-color-white); }
.rx-btn--danger:hover:not(:disabled) { filter: brightness(0.92); }

.rx-btn--ghost { background: transparent; color: var(--rx-color-text-muted); }
.rx-btn--ghost:hover:not(:disabled) { background: var(--rx-color-surface-sunken); color: var(--rx-color-text); }

.rx-btn--sm { padding: 7px 14px; font-size: var(--rx-text-xs); }
.rx-btn--lg { padding: 14px 28px; font-size: var(--rx-text-base); }
.rx-btn--full { width: 100%; }

/* ============================== Badge / Pill ============================== */
.rx-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--rx-space-1);
  font-family: var(--rx-font-body);
  font-weight: var(--rx-weight-semibold);
  font-size: var(--rx-text-xs);
  padding: 3px 10px;
  border-radius: var(--rx-radius-full);
  line-height: 1.4;
}
.rx-badge--neutral  { background: var(--rx-color-surface-sunken); color: var(--rx-color-text-muted); }
.rx-badge--success  { background: var(--rx-color-success-bg); color: var(--rx-color-success); }
.rx-badge--info     { background: var(--rx-color-info-bg); color: var(--rx-color-info); }
.rx-badge--warning  { background: var(--rx-color-warning-bg); color: #8A5A00; }
.rx-badge--danger   { background: var(--rx-color-danger-bg); color: var(--rx-color-danger); }
.rx-badge--brand    { background: var(--rx-color-brand-soft); color: var(--rx-color-brand-strong); }

/* ============================== Alert ============================== */
.rx-alert {
  display: flex;
  gap: var(--rx-space-3);
  align-items: flex-start;
  padding: var(--rx-space-4);
  border-radius: var(--rx-radius-md);
  border-left: 3px solid var(--rx-color-border);
  font-family: var(--rx-font-body);
  font-size: var(--rx-text-sm);
  line-height: var(--rx-leading-normal);
}
.rx-alert--info    { background: var(--rx-color-info-bg); border-left-color: var(--rx-color-info); color: #0B2E6B; }
.rx-alert--success { background: var(--rx-color-success-bg); border-left-color: var(--rx-color-success); color: #0A5C36; }
.rx-alert--warning { background: var(--rx-color-warning-bg); border-left-color: var(--rx-color-warning); color: #7A4E00; }
.rx-alert--danger  { background: var(--rx-color-danger-bg); border-left-color: var(--rx-color-danger); color: #7A1F1F; }
.rx-alert strong { display: block; margin-bottom: 2px; }

/* ============================== Card ============================== */
.rx-card {
  background: var(--rx-color-surface);
  border: 1px solid var(--rx-color-border);
  border-radius: var(--rx-radius-lg);
  box-shadow: var(--rx-shadow-sm);
  padding: var(--rx-space-6);
}
.rx-card--flush { padding: 0; overflow: hidden; }
.rx-card__header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--rx-space-2);
  padding-bottom: var(--rx-space-4); margin-bottom: var(--rx-space-4);
  border-bottom: 1px solid var(--rx-color-border);
}
.rx-card__title {
  font-family: var(--rx-font-display); font-size: var(--rx-text-xl);
  color: var(--rx-color-text); margin: 0;
}
.rx-card__subtitle { font-family: var(--rx-font-body); font-size: var(--rx-text-sm); color: var(--rx-color-text-muted); margin-top: 2px; }

/* ============================== Form field ============================== */
.rx-field { display: flex; flex-direction: column; gap: var(--rx-space-2); }
.rx-field__label {
  font-family: var(--rx-font-body); font-size: var(--rx-text-sm);
  font-weight: var(--rx-weight-medium); color: var(--rx-color-text);
}
.rx-field__hint { font-size: var(--rx-text-xs); color: var(--rx-color-text-muted); }
.rx-field__error { font-size: var(--rx-text-xs); color: var(--rx-color-danger); }
.rx-field__success { font-size: var(--rx-text-xs); color: var(--rx-color-success); }

.rx-input, .rx-select, .rx-textarea {
  font-family: var(--rx-font-body);
  font-size: var(--rx-text-sm);
  color: var(--rx-color-text);
  background: var(--rx-color-surface);
  border: 1px solid var(--rx-color-border);
  border-radius: var(--rx-radius-md);
  padding: 10px 14px;
  width: 100%;
  transition: border-color var(--rx-motion-fast) var(--rx-ease-standard),
              box-shadow var(--rx-motion-fast) var(--rx-ease-standard);
}
.rx-input:focus, .rx-select:focus, .rx-textarea:focus {
  outline: none; border-color: var(--rx-color-brand);
  box-shadow: 0 0 0 3px var(--rx-color-brand-soft);
}
.rx-input.is-invalid, .rx-select.is-invalid, .rx-textarea.is-invalid { border-color: var(--rx-color-danger); }
/* Positive (valid) state -- Baymard: negative-only validation forces users
   to re-audit the whole form before submitting; a green confirmation once a
   field is genuinely correct closes that loop (BOOKING_UX_RESEARCH.md §3.1). */
.rx-input.is-valid, .rx-select.is-valid, .rx-textarea.is-valid { border-color: var(--rx-color-success); }
.rx-textarea { resize: vertical; min-height: 90px; }

/* ============================== Table ============================== */
.rx-table { width: 100%; border-collapse: collapse; font-family: var(--rx-font-body); font-size: var(--rx-text-sm); }
.rx-table th {
  text-align: left; font-size: var(--rx-text-xs); font-weight: var(--rx-weight-semibold);
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--rx-color-text-muted);
  padding: var(--rx-space-3) var(--rx-space-3); border-bottom: 1px solid var(--rx-color-border);
  background: var(--rx-color-surface-alt);
}
.rx-table td { padding: var(--rx-space-3); border-bottom: 1px solid var(--rx-color-border); vertical-align: middle; }
.rx-table tr:hover td { background: var(--rx-color-surface-sunken); }
.rx-table--numeric td.rx-num, .rx-table--numeric th.rx-num { font-family: var(--rx-font-mono); font-variant-numeric: tabular-nums; text-align: right; }

/* ============================== Avatar ============================== */
.rx-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--rx-radius-full);
  background: var(--rx-color-brand-soft); color: var(--rx-color-brand-strong);
  font-family: var(--rx-font-body); font-weight: var(--rx-weight-semibold); font-size: var(--rx-text-sm);
  overflow: hidden;
}
.rx-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rx-avatar--sm { width: 28px; height: 28px; font-size: var(--rx-text-xs); }
.rx-avatar--lg { width: 48px; height: 48px; font-size: var(--rx-text-base); }

/* ============================== Nav item (sidebar / navbar) ============================== */
.rx-nav-item {
  display: flex; align-items: center; gap: var(--rx-space-3);
  padding: 10px var(--rx-space-4); border-radius: var(--rx-radius-md);
  font-family: var(--rx-font-body); font-size: var(--rx-text-sm); font-weight: var(--rx-weight-medium);
  color: var(--rx-color-text-muted); text-decoration: none;
  transition: background-color var(--rx-motion-fast) var(--rx-ease-standard), color var(--rx-motion-fast) var(--rx-ease-standard);
}
.rx-nav-item:hover { background: var(--rx-color-surface-sunken); color: var(--rx-color-text); }
.rx-nav-item.is-active { background: var(--rx-color-brand-soft); color: var(--rx-color-brand-strong); }

/* ============================== Modal shell ============================== */
.rx-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 20, 25, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--rx-z-modal); padding: var(--rx-space-4);
}
.rx-modal {
  background: var(--rx-color-surface); border-radius: var(--rx-radius-lg);
  box-shadow: var(--rx-shadow-md); max-width: 520px; width: 100%;
  padding: var(--rx-space-6);
}
.rx-modal__title { font-family: var(--rx-font-display); font-size: var(--rx-text-xl); margin: 0 0 var(--rx-space-2); }
.rx-modal__actions { display: flex; justify-content: flex-end; gap: var(--rx-space-3); margin-top: var(--rx-space-6); }

/* ============================== Command palette ============================== */
/* Linear's Cmd/Ctrl+K pattern (docs/engineering/MOTION_LANGUAGE.md
   research section 1 -- "keyboard-first is core product philosophy, not
   an accessibility add-on"). Staff-portal-only (layouts/portal_base.html),
   a static filter-as-you-type list for v1 -- see that doc's dated
   section for the full rationale and what's deliberately deferred.

   Deliberately reuses .rx-modal-backdrop for the dim layer and the
   existing .rx-backdrop-enter/leave + .rx-modal-enter/leave transition
   families (both already covered by the shared prefers-reduced-motion
   block below) rather than inventing new enter/leave classes -- same
   "modal gets depth cues" motion as every other dialog in the system,
   per MOTION_LANGUAGE.md 2.4. Positioned near the top of the viewport
   (not vertically centered like .rx-modal) since that's the standard
   command-palette placement -- keeps it out of the way of whatever
   page content is behind it. */
.rx-command-palette {
  position: fixed;
  inset: 0;
  z-index: var(--rx-z-modal);
  display: flex;
  justify-content: center;
  padding: 12vh var(--rx-space-4) var(--rx-space-4);
  pointer-events: none; /* only the panel itself should catch clicks */
}
.rx-command-palette__panel {
  pointer-events: auto;
  width: 100%;
  max-width: 560px;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  background: var(--rx-color-surface);
  border-radius: var(--rx-radius-lg);
  box-shadow: var(--rx-shadow-md);
  overflow: hidden;
}
.rx-command-palette__input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--rx-color-border);
  background: transparent;
  color: var(--rx-color-text);
  font-family: var(--rx-font-body);
  font-size: var(--rx-text-base);
  padding: var(--rx-space-4);
}
.rx-command-palette__input:focus { outline: none; }
.rx-command-palette__list {
  overflow-y: auto;
  padding: var(--rx-space-2);
}
.rx-command-palette__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rx-space-3);
  padding: var(--rx-space-3) var(--rx-space-3);
  border-radius: var(--rx-radius-md);
  color: var(--rx-color-text);
  text-decoration: none;
  font-size: var(--rx-text-sm);
  cursor: pointer;
  transition: background-color var(--rx-motion-instant) var(--rx-ease-standard);
}
.rx-command-palette__item.is-active,
.rx-command-palette__item:hover { background: var(--rx-color-surface-sunken); }
.rx-command-palette__group {
  color: var(--rx-color-text-muted);
  font-size: var(--rx-text-xs);
}
.rx-command-palette__empty {
  padding: var(--rx-space-6) var(--rx-space-4);
  color: var(--rx-color-text-muted);
  font-size: var(--rx-text-sm);
  text-align: center;
}
.rx-command-palette__hint {
  display: flex;
  gap: var(--rx-space-4);
  padding: var(--rx-space-3) var(--rx-space-4);
  border-top: 1px solid var(--rx-color-border);
  color: var(--rx-color-text-muted);
  font-size: var(--rx-text-xs);
}
.rx-command-palette__hint kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 5px;
  margin-right: 2px;
  border: 1px solid var(--rx-color-border);
  border-radius: var(--rx-radius-sm);
  background: var(--rx-color-surface-sunken);
  font-family: var(--rx-font-body);
  font-size: 0.9em;
  text-align: center;
}

/* ============================== Pagination ============================== */
.rx-pagination { display: flex; align-items: center; gap: var(--rx-space-2); font-family: var(--rx-font-body); }
.rx-pagination__item {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 var(--rx-space-2);
  border-radius: var(--rx-radius-md); border: 1px solid var(--rx-color-border);
  background: var(--rx-color-surface); color: var(--rx-color-text);
  font-size: var(--rx-text-sm); font-weight: var(--rx-weight-medium);
  text-decoration: none; cursor: pointer;
  transition: border-color var(--rx-motion-instant) var(--rx-ease-standard), color var(--rx-motion-instant) var(--rx-ease-standard), background-color var(--rx-motion-instant) var(--rx-ease-standard);
}
.rx-pagination__item:hover:not(.is-active):not(.is-disabled):not(:disabled) {
  border-color: var(--rx-color-brand); color: var(--rx-color-brand-strong);
}
.rx-pagination__item.is-active {
  background: var(--rx-color-brand); border-color: var(--rx-color-brand); color: var(--rx-color-ink);
}
.rx-pagination__item.is-disabled, .rx-pagination__item:disabled { opacity: 0.5; cursor: not-allowed; }
.rx-pagination__ellipsis {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; color: var(--rx-color-text-muted); font-size: var(--rx-text-sm);
}

/* ============================== Tabs ============================== */
.rx-tabs {
  display: flex; gap: var(--rx-space-6); border-bottom: 1px solid var(--rx-color-border);
  font-family: var(--rx-font-body);
}
.rx-tabs__item {
  position: relative; padding: var(--rx-space-3) var(--rx-space-1); margin-bottom: -1px;
  font-size: var(--rx-text-sm); font-weight: var(--rx-weight-medium); color: var(--rx-color-text-muted);
  background: none; border: none; cursor: pointer; text-decoration: none;
  transition: color var(--rx-motion-fast) var(--rx-ease-standard);
}
.rx-tabs__item:hover:not(.is-disabled):not(:disabled) { color: var(--rx-color-text); }
.rx-tabs__item.is-active { color: var(--rx-color-ink); font-weight: var(--rx-weight-semibold); }
.rx-tabs__item.is-active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--rx-color-brand); border-radius: var(--rx-radius-full);
}
.rx-tabs__item.is-disabled, .rx-tabs__item:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================== Toast / Notification ============================== */
.rx-toast {
  display: flex; align-items: flex-start; gap: var(--rx-space-3);
  width: 320px; max-width: 100%; padding: var(--rx-space-4);
  border-radius: var(--rx-radius-md); border-left: 3px solid var(--rx-color-border);
  background: var(--rx-color-surface); box-shadow: var(--rx-shadow-md);
  font-family: var(--rx-font-body); font-size: var(--rx-text-sm); line-height: var(--rx-leading-normal);
}
.rx-toast__icon { flex-shrink: 0; font-size: var(--rx-text-lg); line-height: 1; }
.rx-toast__body { flex: 1; }
.rx-toast__body strong { display: block; margin-bottom: 2px; }
.rx-toast__close {
  flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 0;
  font-size: var(--rx-text-base); line-height: 1; color: var(--rx-color-text-muted);
  transition: color var(--rx-motion-fast) var(--rx-ease-standard);
}
.rx-toast__close:hover { color: var(--rx-color-text); }
/* Same bg/border-left/text mapping as .rx-alert's semantic variants above */
.rx-toast--success { background: var(--rx-color-success-bg); border-left-color: var(--rx-color-success); color: #0A5C36; }
.rx-toast--info    { background: var(--rx-color-info-bg); border-left-color: var(--rx-color-info); color: #0B2E6B; }
.rx-toast--warning { background: var(--rx-color-warning-bg); border-left-color: var(--rx-color-warning); color: #7A4E00; }
.rx-toast--danger  { background: var(--rx-color-danger-bg); border-left-color: var(--rx-color-danger); color: #7A1F1F; }

.rx-toast-container {
  position: fixed; display: flex; flex-direction: column; gap: var(--rx-space-3);
  padding: var(--rx-space-6); z-index: var(--rx-z-toast);
}
.rx-toast-container--top-right    { top: 0; right: 0; }
.rx-toast-container--top-left     { top: 0; left: 0; }
.rx-toast-container--bottom-right { bottom: 0; right: 0; }
.rx-toast-container--bottom-left  { bottom: 0; left: 0; }

/* ============================== Empty state ============================== */
.rx-empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--rx-space-12) var(--rx-space-6); font-family: var(--rx-font-body);
}
.rx-empty-state__icon {
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: var(--rx-radius-full);
  background: var(--rx-color-surface-sunken); color: var(--rx-color-text-muted);
  font-size: var(--rx-text-2xl); margin-bottom: var(--rx-space-4);
}
.rx-empty-state__title {
  font-family: var(--rx-font-display); font-size: var(--rx-text-xl); color: var(--rx-color-text); margin: 0 0 var(--rx-space-2);
}
.rx-empty-state__body {
  font-size: var(--rx-text-sm); color: var(--rx-color-text-muted); max-width: 360px; margin: 0;
}
.rx-empty-state__action { margin-top: var(--rx-space-6); }

/* ============================== Skeleton loader ============================== */
.rx-skeleton { position: relative; overflow: hidden; background: var(--rx-color-surface-sunken); border-radius: var(--rx-radius-sm); }
.rx-skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: rx-skeleton-shimmer 1.6s ease-in-out infinite;
}
@keyframes rx-skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.rx-skeleton--text { height: var(--rx-space-3); }
.rx-skeleton--text.rx-skeleton--sm { width: 40%; }
.rx-skeleton--text.rx-skeleton--md { width: 70%; }
.rx-skeleton--text.rx-skeleton--lg { width: 100%; }
.rx-skeleton--avatar { width: 36px; height: 36px; border-radius: var(--rx-radius-full); flex-shrink: 0; }
.rx-skeleton--avatar.rx-skeleton--sm { width: 28px; height: 28px; }
.rx-skeleton--avatar.rx-skeleton--lg { width: 48px; height: 48px; }
.rx-skeleton--card { width: 100%; height: 140px; border-radius: var(--rx-radius-lg); }
.rx-skeleton-group { display: flex; flex-direction: column; gap: var(--rx-space-2); }
.rx-skeleton-group--row { flex-direction: row; align-items: center; gap: var(--rx-space-3); }

/* ============================== Dropdown menu ============================== */
/* Open/closed visibility is left to whoever wires up the markup (same
   assumption as .rx-modal-backdrop above) — this only styles the panel. */
.rx-dropdown { position: relative; display: inline-block; font-family: var(--rx-font-body); }
.rx-dropdown__trigger {
  display: inline-flex; align-items: center; gap: var(--rx-space-2);
  padding: 10px var(--rx-space-4); border-radius: var(--rx-radius-md);
  border: 1px solid var(--rx-color-border); background: var(--rx-color-surface); color: var(--rx-color-text);
  font-size: var(--rx-text-sm); font-weight: var(--rx-weight-medium); cursor: pointer;
  transition: border-color var(--rx-motion-instant) var(--rx-ease-standard), color var(--rx-motion-instant) var(--rx-ease-standard);
}
.rx-dropdown__trigger:hover:not(:disabled):not(.is-disabled) { border-color: var(--rx-color-brand); color: var(--rx-color-brand-strong); }
.rx-dropdown__trigger.is-open { border-color: var(--rx-color-brand); }
.rx-dropdown__trigger:disabled, .rx-dropdown__trigger.is-disabled { opacity: 0.5; cursor: not-allowed; }
.rx-dropdown__menu {
  position: absolute; top: calc(100% + var(--rx-space-2)); left: 0; min-width: 200px;
  background: var(--rx-color-surface); border: 1px solid var(--rx-color-border);
  border-radius: var(--rx-radius-md); box-shadow: var(--rx-shadow-md);
  padding: var(--rx-space-2); z-index: var(--rx-z-dropdown);
}
.rx-dropdown__menu--right { left: auto; right: 0; }
.rx-dropdown__item {
  display: flex; align-items: center; gap: var(--rx-space-3); width: 100%; text-align: left;
  padding: 10px var(--rx-space-3); border-radius: var(--rx-radius-md);
  font-size: var(--rx-text-sm); font-weight: var(--rx-weight-medium); color: var(--rx-color-text-muted);
  background: none; border: none; text-decoration: none; cursor: pointer;
  transition: background-color var(--rx-motion-instant) var(--rx-ease-standard), color var(--rx-motion-instant) var(--rx-ease-standard);
}
/* Hover/active mirror .rx-nav-item exactly, for a consistent interaction feel */
.rx-dropdown__item:hover:not(:disabled):not(.is-disabled) { background: var(--rx-color-surface-sunken); color: var(--rx-color-text); }
.rx-dropdown__item.is-active { background: var(--rx-color-brand-soft); color: var(--rx-color-brand-strong); }
.rx-dropdown__item:disabled, .rx-dropdown__item.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.rx-dropdown__item--danger { color: var(--rx-color-danger); }
.rx-dropdown__item--danger:hover:not(:disabled):not(.is-disabled) { background: var(--rx-color-danger-bg); color: var(--rx-color-danger); }
.rx-dropdown__divider { height: 1px; background: var(--rx-color-border); margin: var(--rx-space-2) 0; border: none; }

/* ============================== Search bar (standalone) ============================== */
/* Distinct from .rx-table-toolbar__search (which is the input already
   embedded in that specific composition) -- this is the general-purpose
   primitive for any other in-page search use. */
.rx-search-bar {
  position: relative;
  display: flex;
  align-items: center;
}
.rx-search-bar__icon {
  position: absolute;
  left: var(--rx-space-3);
  color: var(--rx-color-text-muted);
  pointer-events: none;
  font-size: var(--rx-text-sm);
}
.rx-search-bar .rx-input {
  padding-left: calc(var(--rx-space-3) * 2 + 14px);
}

/* ============================== Drawer ============================== */
/* Same backdrop convention as .rx-modal-backdrop; slides from the
   right rather than centering. Open/close state left to Alpine
   (x-show on both backdrop and panel), same as modal/dropdown. */
.rx-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.55);
  z-index: var(--rx-z-modal);
}
.rx-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 420px;
  max-width: 100%;
  background: var(--rx-color-surface);
  box-shadow: var(--rx-shadow-lg);
  z-index: calc(var(--rx-z-modal) + 1);
  display: flex;
  flex-direction: column;
}

/* ---------- Alpine x-transition classes (drawer, backdrop, modal, dropdown) ----------
 * A plain CSS `transition:` property does nothing for an x-show-toggled
 * `display:none` element -- display can't be transitioned. Alpine's
 * x-transition:enter/leave classes are the correct mechanism: Alpine
 * applies the *-start class, forces a frame, swaps to the *-end class
 * (letting the transition class's `transition:` property animate
 * between them), then removes display:none only after the leave
 * transition finishes. Entering elements use --rx-ease-decelerate
 * (fast start, gentle settle); leaving elements use --rx-ease-accelerate
 * (matches how attention leaves a dismissed element) -- see
 * docs/engineering/MOTION_LANGUAGE.md.
 */
.rx-backdrop-enter { transition: opacity var(--rx-motion-base) var(--rx-ease-standard); }
.rx-backdrop-enter-start, .rx-backdrop-leave-end { opacity: 0; }
.rx-backdrop-enter-end, .rx-backdrop-leave-start { opacity: 1; }
.rx-backdrop-leave { transition: opacity var(--rx-motion-fast) var(--rx-ease-standard); }

.rx-drawer-enter { transition: transform var(--rx-motion-base) var(--rx-ease-decelerate); }
.rx-drawer-enter-start, .rx-drawer-leave-end { transform: translateX(100%); }
.rx-drawer-enter-end, .rx-drawer-leave-start { transform: translateX(0); }
.rx-drawer-leave { transition: transform var(--rx-motion-fast) var(--rx-ease-accelerate); }

.rx-modal-enter { transition: opacity var(--rx-motion-base) var(--rx-ease-decelerate), transform var(--rx-motion-base) var(--rx-ease-decelerate); }
.rx-modal-enter-start, .rx-modal-leave-end { opacity: 0; transform: scale(0.96) translateY(8px); }
.rx-modal-enter-end, .rx-modal-leave-start { opacity: 1; transform: scale(1) translateY(0); }
.rx-modal-leave { transition: opacity var(--rx-motion-fast) var(--rx-ease-accelerate), transform var(--rx-motion-fast) var(--rx-ease-accelerate); }

.rx-menu-enter { transition: opacity var(--rx-motion-fast) var(--rx-ease-decelerate), transform var(--rx-motion-fast) var(--rx-ease-decelerate); }
.rx-menu-enter-start, .rx-menu-leave-end { opacity: 0; transform: translateY(-4px) scale(0.98); }
.rx-menu-enter-end, .rx-menu-leave-start { opacity: 1; transform: translateY(0) scale(1); }
.rx-menu-leave { transition: opacity var(--rx-motion-instant) var(--rx-ease-accelerate), transform var(--rx-motion-instant) var(--rx-ease-accelerate); }
.rx-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rx-space-5) var(--rx-space-6);
  border-bottom: 1px solid var(--rx-color-border);
}
.rx-drawer__title {
  font-family: var(--rx-font-display);
  font-size: var(--rx-text-xl);
  margin: 0;
}
.rx-drawer__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--rx-text-lg);
  color: var(--rx-color-text-muted);
}
.rx-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--rx-space-6);
}
.rx-drawer__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--rx-space-3);
  padding: var(--rx-space-4) var(--rx-space-6);
  border-top: 1px solid var(--rx-color-border);
}

/* ============================== Confirmation dialog ============================== */
/* A constrained variant of .rx-modal for the single most common modal
   use case (destructive/irreversible action confirmation) -- narrower,
   centered icon, no free-form body layout. For anything else, use
   .rx-modal directly rather than stretching this one. */
.rx-confirm-dialog {
  background: var(--rx-color-surface);
  border-radius: var(--rx-radius-lg);
  box-shadow: var(--rx-shadow-md);
  max-width: 400px;
  width: 100%;
  padding: var(--rx-space-6);
  text-align: center;
}
.rx-confirm-dialog__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--rx-radius-full);
  margin: 0 auto var(--rx-space-4);
  font-size: var(--rx-text-xl);
}
.rx-confirm-dialog__icon--danger { background: var(--rx-color-danger-bg); color: var(--rx-color-danger); }
.rx-confirm-dialog__icon--warning { background: var(--rx-color-warning-bg); color: var(--rx-color-warning); }
.rx-confirm-dialog__title {
  font-family: var(--rx-font-display);
  font-size: var(--rx-text-lg);
  margin: 0 0 var(--rx-space-2);
}
.rx-confirm-dialog__body {
  font-size: var(--rx-text-sm);
  color: var(--rx-color-text-muted);
  margin: 0 0 var(--rx-space-6);
}
.rx-confirm-dialog__actions {
  display: flex;
  gap: var(--rx-space-3);
}
.rx-confirm-dialog__actions .rx-btn { flex: 1; }

/* ============================== Breadcrumb ============================== */
.rx-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: var(--rx-space-2); font-family: var(--rx-font-body); font-size: var(--rx-text-sm); }
.rx-breadcrumb__item { display: flex; align-items: center; gap: var(--rx-space-2); color: var(--rx-color-text-muted); }
.rx-breadcrumb__link { color: var(--rx-color-text-muted); text-decoration: none; transition: color var(--rx-motion-fast) var(--rx-ease-standard); }
.rx-breadcrumb__link:hover { color: var(--rx-color-brand-strong); }
.rx-breadcrumb__item.is-current { color: var(--rx-color-text); font-weight: var(--rx-weight-medium); }
.rx-breadcrumb__separator { color: var(--rx-color-border); }

/* ============================== Layout primitives ============================== */
/* Cover the large majority of layout needs seen across the existing
   components (button rows, form field rows, card grids) without pulling
   in a full utility-class framework -- see FRONTEND_ARCHITECTURE.md
   section 4 for why Tailwind/Bootstrap's grid was deliberately not
   added as a second dependency when two primitives cover it. */
.rx-stack {
  display: flex;
  flex-direction: column;
  gap: var(--rx-space-4);
}
.rx-stack--row { flex-direction: row; align-items: center; flex-wrap: wrap; }
.rx-stack--sm { gap: var(--rx-space-2); }
.rx-stack--lg { gap: var(--rx-space-6); }

.rx-grid {
  display: grid;
  gap: var(--rx-space-6);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.rx-grid--tight { gap: var(--rx-space-4); }
.rx-grid--2up { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.rx-container {
  width: 100%;
  max-width: 1280px; /* == --rx-bp-xl */
  margin: 0 auto;
  padding: 0 var(--rx-space-6);
}
@media (max-width: 767px) { /* == --rx-bp-md - 1px */
  .rx-container { padding: 0 var(--rx-space-4); }
}

/* ============================== Focus states (accessibility) ============================== */
/* :focus-visible only (not plain :focus) so mouse/touch clicks don't
   show a ring -- keyboard/programmatic focus does. Every interactive
   primitive gets the same treatment for a consistent, predictable
   keyboard-navigation experience. Form inputs keep their existing
   box-shadow focus style above (already present); this covers the
   primitives that had none. */
.rx-btn:focus-visible,
.rx-nav-item:focus-visible,
.rx-pagination__item:focus-visible,
.rx-tabs__item:focus-visible,
.rx-toast__close:focus-visible,
.rx-dropdown__trigger:focus-visible,
.rx-dropdown__item:focus-visible,
.rx-breadcrumb__link:focus-visible,
.rx-fare-card__select:focus-visible,
.rx-fare-card__toggle:focus-visible,
.rx-route-summary__edit:focus-visible,
.rx-shell__icon-btn:focus-visible,
.rx-command-palette__item:focus-visible,
.rx-skip-link:focus-visible,
.rx-shell__topbar-toggle:focus-visible {
  /* Was --rx-color-brand-strong, a dark gold tuned for text-on-light: it
     measured 2.39-2.93:1 against the dark theme's three surfaces, under
     WCAG 1.4.11's 3:1 floor for a focus indicator -- i.e. keyboard focus
     was effectively invisible on every dark-theme page. --rx-color-focus-ring
     inverts per theme and clears 3:1 in both (tokens.css). */
  outline: 2px solid var(--rx-color-focus-ring);
  outline-offset: 2px;
}

/* .rx-fare-card is a <div> wrapper, not the focusable control -- the
   selector above used to target it, left over from before the nested-
   <button> fix (MOBILE_RESPONSIVENESS_REVIEW_2.md finding 1) moved the
   click target into .rx-fare-card__select. Mirror the ring onto the card
   so the whole vehicle option reads as focused, not just the inner row. */
.rx-fare-card:has(.rx-fare-card__select:focus-visible) {
  border-color: var(--rx-color-focus-ring);
}

/* ============================== Spinner ============================== */
.rx-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--rx-color-border);
  border-top-color: var(--rx-color-brand-strong);
  border-radius: 50%;
  animation: rx-spin 0.7s linear infinite;
}
.rx-spinner--sm { width: 14px; height: 14px; border-width: 2px; }
.rx-spinner--lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes rx-spin { to { transform: rotate(360deg); } }

/* ============================== HTMX loading/transition conventions ============================== */
/* Standard htmx-indicator convention: any element with this class is
   hidden by default and shown while the request it's attached to (via
   hx-indicator, or a request on itself/an ancestor) is in flight. Use
   this for a per-button/per-row spinner; use #rx-global-progress
   (portal_base.html) for whole-page navigation. */
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* Content fade during an hx-swap, so a swapped-in fragment doesn't pop
   in abruptly. Opt-in per element via hx-swap="innerHTML swap:150ms"
   (or similar) -- this just styles the transition htmx's swap timing
   hooks into, it doesn't force it on every request. */
.htmx-swapping { opacity: 0; transition: opacity 150ms ease-out; }
.htmx-settling { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .rx-btn, .rx-input, .rx-select, .rx-textarea, .rx-nav-item,
  .rx-pagination__item, .rx-tabs__item, .rx-toast__close,
  .rx-dropdown__trigger, .rx-dropdown__item, .rx-breadcrumb__link,
  .rx-backdrop-enter, .rx-backdrop-leave, .rx-drawer-enter, .rx-drawer-leave,
  .rx-modal-enter, .rx-modal-leave, .rx-menu-enter, .rx-menu-leave,
  .rx-shell__sidebar, .rx-shell__icon-btn { transition: none; }
  .rx-skeleton::after { animation: none; }
  .rx-spinner { animation-duration: 1.4s; }
}

/* ==================================================================== */
/* == WCAG AA contrast corrections (ACCESSIBILITY_AUDIT.md findings 3-5) */
/* ==================================================================== */
/*
 * Appended as an override block rather than edited in place above, so
 * this lands cleanly alongside parallel work touching the same file.
 * Each rule below re-points ONE color declaration at a theme-aware
 * token; no geometry, spacing, or layout property is touched.
 *
 * Root cause: the status hues (--rx-color-success/info/warning/danger)
 * and the hardcoded alert/toast text hexes were all chosen against
 * *light* tinted containers, but tokens.css's dark theme inverts only
 * the --*-bg halves. Every badge/alert/toast therefore rendered dark
 * text on a dark container in dark mode -- measured as low as 1.25:1
 * against a 4.5:1 requirement. The --rx-color-on-*-bg tokens are the
 * matching foreground halves and invert with their containers.
 */
.rx-badge--success  { color: var(--rx-color-on-success-bg); }
.rx-badge--info     { color: var(--rx-color-on-info-bg); }
.rx-badge--warning  { color: var(--rx-color-on-warning-bg); }
.rx-badge--danger   { color: var(--rx-color-on-danger-bg); }

.rx-alert--info     { color: var(--rx-color-on-info-bg); }
.rx-alert--success  { color: var(--rx-color-on-success-bg); }
.rx-alert--warning  { color: var(--rx-color-on-warning-bg); }
.rx-alert--danger   { color: var(--rx-color-on-danger-bg); }

.rx-toast--success  { color: var(--rx-color-on-success-bg); }
.rx-toast--info     { color: var(--rx-color-on-info-bg); }
.rx-toast--warning  { color: var(--rx-color-on-warning-bg); }
.rx-toast--danger   { color: var(--rx-color-on-danger-bg); }

/* Inline field validation text sits on a plain surface, not a tinted
   container, but has the same problem: --rx-color-danger was 4.02:1 on
   white (needs 4.5:1) and --rx-color-success 3.03:1 on the dark surface. */
.rx-field__error    { color: var(--rx-color-on-danger-bg); }
.rx-field__success  { color: var(--rx-color-on-success-bg); }

/* WCAG 1.4.11 non-text contrast (3:1): the border is what identifies an
   input as an input. --rx-color-border measured 1.30:1 (light) / 1.48:1
   (dark) on its own surface. Scoped to form controls only -- card and
   table dividers keep the lighter --rx-color-border on purpose. */
.rx-input, .rx-select, .rx-textarea { border-color: var(--rx-color-border-strong); }
/* Validity borders likewise need 3:1; --rx-color-danger is only 2.91:1
   on the dark surface, so these use the theme-aware foreground tokens. */
.rx-input.is-invalid, .rx-select.is-invalid, .rx-textarea.is-invalid { border-color: var(--rx-color-on-danger-bg); }
.rx-input.is-valid, .rx-select.is-valid, .rx-textarea.is-valid { border-color: var(--rx-color-on-success-bg); }

/* ==================================================================== */
/* == Skip link (WCAG 2.4.1 Bypass Blocks)                             == */
/* ==================================================================== */
/* Visually hidden until focused, then pinned to the top-left. Both
   portal_base and enduser_base render one as their first focusable
   element so a keyboard user isn't forced through the whole sidebar /
   top nav on every page load. */
.rx-skip-link {
  position: absolute;
  left: var(--rx-space-2);
  top: -100px;
  z-index: var(--rx-z-toast);
  padding: var(--rx-space-3) var(--rx-space-4);
  background: var(--rx-color-surface);
  color: var(--rx-color-text);
  border: 2px solid var(--rx-color-focus-ring);
  border-radius: var(--rx-radius-md);
  font-size: var(--rx-text-sm);
  font-weight: var(--rx-weight-medium);
  text-decoration: none;
  transition: top var(--rx-motion-fast) var(--rx-ease-decelerate);
}
.rx-skip-link:focus { top: var(--rx-space-2); }
@media (prefers-reduced-motion: reduce) {
  .rx-skip-link { transition: none; }
}

/* Row headers (crud/_list_results.html renders the first list column as
   <th scope="row"> so each row has programmatic context for its
   repeated View/Edit/History links). Without this they would inherit
   .rx-table th's column-header treatment -- uppercase, 12px, muted, on
   a grey fill -- and the first data column would visibly change. These
   must read exactly like the <td>s beside them. */
.rx-table tbody th[scope="row"] {
  text-transform: none;
  letter-spacing: normal;
  font-size: var(--rx-text-sm);
  font-weight: var(--rx-weight-regular);
  color: var(--rx-color-text);
  background: transparent;
  padding: var(--rx-space-3);
  vertical-align: middle;
}
.rx-table tr:hover tbody th[scope="row"],
.rx-table tbody tr:hover th[scope="row"] { background: var(--rx-color-surface-sunken); }

/* Keyboard access to horizontally scrollable table wrappers. An
   overflow-x:auto container with no focusable child cannot be scrolled
   by keyboard at all; tabindex="0" + a group role/label makes it a
   reachable, named scroll region. */
.rx-table-scroll:focus-visible {
  outline: 2px solid var(--rx-color-focus-ring);
  outline-offset: 2px;
}

/* Screen-reader-only utility, for text that must be announced but not
   shown (e.g. the booking wizard's aria-live status region). Standard
   clip-rect pattern -- stays in the a11y tree, unlike display:none. */
.rx-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==================================================================== */
/* == Page Builder section reorder (static/js/design_system/          == */
/* == section_reorder.js) -- plumbing only, inert until a future Page  == */
/* == Editor mounts it AND window.RX_FEATURE_FLAGS.dragDropPageBuilder == */
/* == is set true (see that file's own top comment). No template in    == */
/* == this codebase renders these classes yet; kept deliberately       == */
/* == minimal per this task's own scope ("zero visual polish") --      == */
/* == a future Design System pass owns the real look.                  == */
/* ==================================================================== */
.rx-section-reorder__handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--rx-radius-md);
  color: var(--rx-color-text-muted);
  cursor: grab;
  user-select: none;
}
.rx-section-reorder__handle:active { cursor: grabbing; }

/* Drop-target affordance shown at the current drag position -- a plain
   outline, not an animated insert; see section_reorder.js's
   placeholderIndex state for what drives x-show on this element. */
.rx-section-reorder__placeholder {
  height: 8px;
  margin: var(--rx-space-2) 0;
  border: 2px dashed var(--rx-color-border-strong);
  border-radius: var(--rx-radius-md);
  background: var(--rx-color-surface-sunken);
}
