/* ==========================================================
   seats.css — seat selection panel, realistic bus + seats
   Load AFTER results.css:
   <link rel="stylesheet" href="results.css">
   <link rel="stylesheet" href="seats.css">
   No HTML changes needed: same classes as before
   (.bus-wrap, .bus, .seat.vip/.normal/.business/.booked/.selected,
    .vip-tag, em, .wheel, .door)
   ========================================================== */

:root {
  --seat-vip: #d97706;
  --seat-normal: #1f6fb5;
  --seat-business: #2f8a4d;
  --seat-booked: #8b909c;
  --seat-selected: #e0480b;
  --bus-shell: #2d3238;
}

/* ---------- Layout ---------- */
.results-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; transition: grid-template-columns .32s cubic-bezier(.2,.75,.25,1); }
#tripList { min-width: 0; }
.booking-details { position: fixed; z-index: 51; inset: 0 0 0 auto; width: min(520px, calc(100vw - 32px)); height: 100vh; height: 100dvh; padding: 24px; overflow-y: auto; background: #fff; color: #111; box-shadow: -12px 0 36px rgba(0,0,0,.2); transform: translateX(105%); visibility: hidden; transition: transform .28s cubic-bezier(.2,.75,.25,1), visibility 0s linear .28s; }
.booking-details:not([hidden]) { transform: translateX(0); visibility: visible; transition-delay: 0s; }
.booking-details[hidden], .booking-step-action[hidden], .booking-step-continue[hidden], .booking-step-hint[hidden], .booking-leg-field[hidden] { display: none !important; }
.booking-details-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 18px; padding-bottom: 14px; border-bottom: 1px solid #e8e9ec; }
.booking-details h2 { margin: 0; color: #242424; font: 700 18px/1.3 Lato, Inter, sans-serif; }
.booking-leg-field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.booking-leg-field select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid #d6d6d6; border-radius: 0; background: #fff; font: 500 13px Lato, Inter, sans-serif; color: #111; }
.booking-leg-field select:focus { outline: 0; border-color: #e85d04; box-shadow: 0 0 0 3px rgba(232,93,4,.1); }
.booking-details .points { grid-template-columns: 1fr; gap: 14px; margin-top: 0; }
.booking-details .panel-action { display: flex; flex-direction: column; align-items: flex-start; }
.booking-details .continue { max-width: 100%; }
.selected-seats-summary { margin-top: 12px; padding: 0 8px; }
.selected-seats-summary h3 { font-size: 13px; }
.booking-step-action { position: sticky; bottom: 0; z-index: 3; margin-top: 14px; padding: 12px 0; background: #fff; box-shadow: 0 -7px 16px rgba(0,0,0,.08); }
.booking-step-hint { margin: 0 0 10px; color: #6b4a1f; font-size: 12px; line-height: 1.5; }
.booking-step-continue:not([hidden]) { display: flex; margin-top: 0; }
.booking-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.48); opacity: 1; }
.booking-backdrop[hidden] { display: none !important; }

.seat-panel {
  display: none;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  border: 1px solid #e9e9e9;
  border-radius: 0;
  background: #fff;
  font-family: Lato, Inter, sans-serif;
  color: #111;
  box-shadow: 0 8px 28px rgba(20,25,35,.08);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 10px; }
.sheet-head strong { font-size: 15px; font-weight: 700; }
.sheet-grab { display: none; }
.sheet-close { border: 0; background: transparent; color: #444; cursor: pointer; padding: 4px; display: grid; place-items: center; }

.sheet-backdrop { display: none; }

/* ---------- Desktop: side panel ---------- */
@media (min-width: 861px) {
  .results-layout.has-open { grid-template-columns: minmax(0, 1fr) 440px; }
  .results-layout.has-open .seat-panel { display: block; position: sticky; top: 12px; animation: seat-panel-enter .28s cubic-bezier(.2,.75,.25,1) both; }
  @keyframes seat-panel-enter { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: translateX(0); } }

  .has-open .trip-card { padding-right: 16px; }
  .has-open .t-type { flex: 0 0 80px; padding-left: 10px; }
  .has-open .t-dep { flex: 0 0 130px; }
  .has-open .t-code { min-width: 0; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .has-open .t-dur { flex: 1 1 90px; min-width: 0; margin: 0 4px; }
  .has-open .t-arr { flex: 0 0 100px; }
  .has-open .t-rate, .has-open .t-price { display: none; }
  .has-open .price-one { display: block; margin-left: auto; }
}
.price-one { display: none; margin-left: auto; color: #e85d04; font: 700 15px/1 Lato, Inter, sans-serif; white-space: nowrap; }
.trip-card.is-open { border-color: #111; background: #f7f7f7; }

/* ---------- Legend (mini seats) ---------- */
.seat-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 16px; margin: 4px 0 12px; font-size: 12px; color: #333; }
.seat-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg {
  display: inline-block; width: 18px; height: 18px;
  border-radius: 6px 6px 3px 3px;
  border-bottom: 4px solid rgba(0,0,0,.25);
}
.lg.vip { background: var(--seat-vip); }
.lg.normal { background: var(--seat-normal); }
.lg.business { background: var(--seat-business); }
.lg.booked { background: var(--seat-booked); opacity: .6; }

/* ==========================================================
   BUS BODY
   ========================================================== */
.bus-wrap {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 8px auto 4px;
  padding: 14px 22px 26px;
  display: flex; flex-direction: column; align-items: center;
  border: 3px solid var(--bus-shell);
  border-bottom-width: 7px;
  border-radius: 64px 64px 16px 16px;
  background:
    /* tail lights */
    linear-gradient(#e5383b, #e5383b) 16px calc(100% - 8px) / 26px 5px no-repeat,
    linear-gradient(#e5383b, #e5383b) calc(100% - 16px) calc(100% - 8px) / 26px 5px no-repeat,
    /* body */
    linear-gradient(180deg, #f2f4f7, #fff 30%);
  box-shadow: 0 10px 22px rgba(20,25,35,.14), inset 0 0 0 4px #fff, inset 0 0 0 5px #dfe3e8;
}

/* windshield */
.bus-wrap::before {
  content: 'FRONT OF COACH';
  align-self: stretch;
  margin-bottom: 12px;
  padding: 11px 0 9px;
  border-radius: 46px 46px 6px 6px;
  background:
    linear-gradient(115deg, transparent 38%, rgba(255,255,255,.6) 44%, transparent 54%),
    linear-gradient(180deg, #a9d2ee, #dcedf8);
  border: 2px solid var(--bus-shell);
  color: #3a6683;
  font: 700 9px/1.2 Inter, sans-serif;
  letter-spacing: 1.4px;
  text-align: center;
}

/* side mirrors */
.bus-wrap::after {
  content: '';
  position: absolute;
  top: 70px; left: -16px; right: -16px; height: 22px;
  pointer-events: none;
  background:
    linear-gradient(var(--bus-shell), var(--bus-shell)) left / 12px 100% no-repeat,
    linear-gradient(var(--bus-shell), var(--bus-shell)) right / 12px 100% no-repeat;
}

/* floor + aisle carpet */
.bus {
  position: relative;
  display: grid;
  /* 1,2 = left pair · 3 = aisle · 4,5 = right pair */
  grid-template-columns: 42px 42px 28px 42px 42px;
  grid-template-rows: 50px repeat(12, 46px);
  gap: 8px 6px;
  justify-content: center;
  padding: 10px 8px 12px;
  border-radius: 8px;
  background: #e7eaee;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.10);
}
.bus::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 28px; transform: translateX(-50%);
  background:
    repeating-linear-gradient(180deg, transparent 0 10px, rgba(255,255,255,.35) 10px 12px),
    #9aa3b2;
  opacity: .55;
  pointer-events: none;
}

/* ==========================================================
   REALISTIC SEAT
   backrest + headrest (::before) · cushion + armrests (::after)
   ========================================================== */
.seat {
  --c: var(--seat-normal);
  --c-light: color-mix(in srgb, var(--c) 72%, #fff);
  --c-dark: color-mix(in srgb, var(--c) 72%, #000);

  position: relative; isolation: isolate;
  width: 100%; height: 100%;
  padding: 0 0 7px; margin: 0;
  border: 0; border-radius: 0;
  background: none; box-shadow: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 800 12px/1 Lato, Inter, sans-serif;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s cubic-bezier(.3,1.6,.5,1), filter .15s;
  animation: seat-arrive .3s cubic-bezier(.2,.75,.25,1) both;
  animation-delay: calc(var(--seat-order, 0) * 8ms);
}

/* backrest + headrest */
.seat::before {
  content: '';
  position: absolute; z-index: -1;
  inset: 0 3px 9px;
  border-radius: 12px 12px 5px 5px;
  background:
    linear-gradient(rgba(255,255,255,.28), rgba(255,255,255,.28)) 50% 3px / 56% 5px no-repeat,
    linear-gradient(90deg, rgba(0,0,0,.10), transparent 22%, transparent 78%, rgba(0,0,0,.10)),
    linear-gradient(180deg, var(--c-light), var(--c) 70%);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.14), 0 2px 3px rgba(0,0,0,.28);
}
/* cushion + armrests */
.seat::after {
  content: '';
  position: absolute; z-index: -1;
  left: 0; right: 0; bottom: 0; height: 17px;
  border-radius: 7px 7px 10px 10px;
  background:
    linear-gradient(90deg, var(--c-dark) 0 6px, transparent 6px calc(100% - 6px), var(--c-dark) calc(100% - 6px)),
    linear-gradient(180deg, var(--c), var(--c-dark));
  box-shadow: inset 0 2px 0 rgba(255,255,255,.22), 0 3px 4px rgba(0,0,0,.30);
}

.seat.vip { --c: var(--seat-vip); }
.seat.normal { --c: var(--seat-normal); }
.seat.business { --c: var(--seat-business); }

.seat .seat-type { font-size: 6px; font-weight: 800; letter-spacing: .2px; margin-bottom: 3px; white-space: nowrap; }
.seat em { font-style: normal; font-size: 13px; }

/* hover / focus */
.seat.free:hover { transform: translateY(-3px); filter: brightness(1.08); }
.seat:focus-visible { outline: 2px solid #111; outline-offset: 3px; border-radius: 8px; }

/* selected */
.seat.selected {
  --c: var(--seat-selected);
  animation: seat-pop .5s cubic-bezier(.2,.9,.3,1) both;
  animation-delay: 0s;
}
.seat.selected::before { box-shadow: inset 0 -3px 0 rgba(0,0,0,.14), 0 0 0 2px #fff, 0 0 0 4px var(--seat-selected); }

/* booked */
.seat.booked, .seat:disabled {
  --c: var(--seat-booked);
  opacity: .55; cursor: not-allowed; filter: grayscale(.4);
}
.seat.booked::before, .seat:disabled::before { box-shadow: inset 0 -3px 0 rgba(0,0,0,.10); }
.seat.booked::after, .seat:disabled::after { box-shadow: inset 0 2px 0 rgba(255,255,255,.2); }
.seat.booked:hover, .seat:disabled:hover { transform: none; filter: grayscale(.4); }

/* ---------- Animations ---------- */
@keyframes seat-arrive { from { opacity: 0; transform: translateY(6px) scale(.9); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* POP on click: squash, big overshoot, settle + glow pulse */
@keyframes seat-pop {
  0%   { transform: scale(1); filter: drop-shadow(0 0 0 rgba(224,72,11,0)); }
  25%  { transform: scale(.82, .88); }
  55%  { transform: scale(1.28, 1.2) rotate(-3deg); filter: drop-shadow(0 0 10px rgba(224,72,11,.75)); }
  75%  { transform: scale(.95) rotate(1.5deg); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(224,72,11,0)); }
}

/* ---------- Wheel + door ---------- */
.wheel {
  display: grid; place-items: center; color: #222;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
}
.door {
  display: grid; place-items: center;
  position: relative;
  border: 2px solid #5b6572; border-radius: 4px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), #5b6572 calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(115deg, transparent 35%, rgba(255,255,255,.55) 42%, transparent 52%),
    linear-gradient(180deg, #bcdcf1, #e4f1fa);
  color: #3a4654; font-size: 11px;
}
.door b { font-weight: 700; font-size: 10px; letter-spacing: 1px; writing-mode: vertical-rl; transform: rotate(180deg); background: rgba(255,255,255,.7); padding: 4px 1px; }

/* ---------- Summary ---------- */
.sel-summary h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.sel-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 28px; font-size: 13px; color: #444; }
.sel-list .none { color: #555; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-radius: 0; background: #f1f1f1; border: 1px solid #e0e0e0; font-size: 12px; font-weight: 600; animation: chip-pop .3s cubic-bezier(.2,.9,.3,1.4) both; }
@keyframes chip-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
.chip button { width: 22px; height: 22px; border: 0; border-radius: 0; background: #d8d8d8; color: #111; font-size: 13px; line-height: 1; cursor: pointer; }
.chip button:hover { background: #111; color: #fff; }
.sel-total { flex-basis: 100%; margin-top: 4px; font-size: 13px; }
.sel-total b { color: #e85d04; }

.points { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.points label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.points label > select, .points label > input { grid-column: 1 / -1; }
.required-mark { color: #e85d04; font-size: 9px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.points select, .points input {
  width: 100%; height: 40px; padding: 0 10px;
  border: 1px solid #d6d6d6; border-radius: 0; background: #fff;
  font: 500 13px Lato, Inter, sans-serif; color: #111;
  transition: border-color .18s, box-shadow .18s;
}
.points select:focus, .points input:focus { outline: 0; border-color: #e85d04; box-shadow: 0 0 0 3px rgba(232,93,4,.1); }
.points input::placeholder { color: #8a8a8a; font-weight: 400; }

.panel-action { margin-top: 14px; }
.continue {
  width: 100%; min-height: 46px; border: 0; border-radius: 2px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #e88a00; color: #201608; font: 700 13px Lato, Inter, sans-serif; cursor: pointer; transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.continue:hover:not(:disabled) { background: #ffb321; transform: translateY(-1px); box-shadow: 0 5px 14px #e88a0030; }
.continue:active:not(:disabled) { transform: translateY(0); }
.continue:focus-visible, .sheet-close:focus-visible, .points select:focus-visible, .points input:focus-visible { outline: 3px solid #ffca61; outline-offset: 2px; }
.continue:disabled { background: #9a9aa8; cursor: not-allowed; }
.continue .info { width: 16px; height: 16px; border-radius: 50%; background: #fff; color: #9a9aa8; display: grid; place-items: center; font-size: 11px; font-weight: 800; }

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 860px) {
  .seat-panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    max-height: 88vh;
    overflow: hidden;
    display: flex; flex-direction: column;
    border-radius: 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.2);
    transform: translateY(100%);
    transition: transform .3s ease;
    visibility: hidden;
  }

  .results-layout.has-open .seat-panel { transform: translateY(0); visibility: visible; }

  .sheet-head { position: relative; padding: 18px 20px 12px; background: #fff9ed; border-radius: 0; border-bottom: 1px solid #e6e6e6; }
  .sheet-grab { display: block; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 99px; background: #cfcfcf; }
  .panel-body { min-height: 0; overflow-y: auto; padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
  .seat-legend { justify-content: flex-start; }
  .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sheet-backdrop.show { opacity: 1; pointer-events: auto; }

  .booking-details { inset: auto 0 0; width: 100%; height: auto; max-height: min(90dvh, 760px); padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.2); transform: translateY(105%); }
  .booking-details:not([hidden]) { transform: translateY(0); }
  .booking-details-head { margin: 0 0 16px; }
  .booking-details .points { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .seat-panel { max-height: 90vh; max-height: min(90dvh, 760px); padding-bottom: env(safe-area-inset-bottom); }
}
@media (max-width: 420px) {
  .bus-wrap { padding: 12px 16px 24px; }
  .bus { grid-template-columns: 38px 38px 22px 38px 38px; grid-template-rows: 46px repeat(12, 42px); gap: 7px 5px; padding: 8px 6px 10px; }
  .bus::before { width: 22px; }
  .seat em { font-size: 12px; }
  .panel-body { padding-right: 12px; padding-left: 12px; }
  .seat-legend { gap: 8px 12px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .results-layout, .seat-panel, .booking-details, .seat, .chip, .sheet-backdrop, .booking-backdrop { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Booking progress overlay ---------- */
.booking-progress[hidden] { display: none !important; }
.booking-progress {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 20, 28, .62);
}
.booking-progress-card {
  width: min(100%, 390px);
  padding: 28px 24px;
  border-radius: 16px;
  background: #fff;
  color: #17212b;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .24);
}
.booking-progress-spinner {
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto 18px;
  border: 4px solid #e8ebef;
  border-top-color: #b8860b;
  border-radius: 50%;
  animation: booking-progress-spin .8s linear infinite;
}
.booking-progress-card h2 { margin: 0 0 10px; font-size: 20px; }
.booking-progress-card p { margin: 0; color: #5b6570; line-height: 1.55; }
@keyframes booking-progress-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .booking-progress-spinner { animation-duration: 1.8s; }
}