/* ============================================================
   Seat Map — layout tokens + seat button styles
   Override pattern from JS (SeatMapLayout.applyCssVars):
     --seat-size, --seat-gap, --section-gap, --row-pitch,
     --curve-depth, --seat-start-y, --map-center-x
   Position each seat with:
     --seat-x, --seat-y  (set by SeatMapLayout.placeNode)
   ============================================================ */

#seat-map-shell {
  --seat-size: 26px;
  --seat-gap: 6px;
  --section-gap: 34px;
  --row-pitch: 34px;
  --curve-depth: 36px;
  --seat-start-y: 220px;
  --map-center-x: 490px;
  --canvas-width: 980px;

  background: #F4F5F7;
  border: 1px solid #e5e7eb;
  border-radius: 1.5rem;
  position: relative;
  height: min(72vh, 640px);
  overflow: hidden;
  user-select: none;
}

/* Availability loading / error overlay on the map shell (like floor loading). */
#seat-map-shell.is-availability-loading #seat-viewport,
#seat-map-shell.is-availability-error #seat-viewport {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.seat-availability-overlay {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(244, 245, 247, 0.55);
  backdrop-filter: blur(1px);
  pointer-events: auto;
}

.seat-availability-overlay[hidden] {
  display: none !important;
}

.seat-availability-overlay__panel {
  width: min(16rem, 80%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.seat-availability-overlay__track {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: rgba(91, 63, 248, 0.15);
  overflow: hidden;
}

.seat-availability-overlay__bar {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: #5B3FF8;
  animation: seat-availability-indeterminate 1.1s ease-in-out infinite;
}

.seat-availability-overlay.is-error .seat-availability-overlay__track {
  display: none;
}

.seat-availability-overlay__label {
  margin: 0;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.4;
  color: #4b5563;
}

.seat-availability-overlay.is-error .seat-availability-overlay__label {
  color: #b91c1c;
}

@keyframes seat-availability-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

/* Mobile: default taller only while zoomed-in panning; at fit JS sets is-map-height-fitted. */
@media (max-width: 1023px) {
  #seat-map-shell:not(.is-map-height-fitted) {
    height: min(62vh, 520px);
    min-height: 240px;
  }
  #seat-map-shell.is-map-height-fitted {
    min-height: 240px;
    max-height: min(62vh, 520px);
  }
}

@media (min-width: 1024px) {
  #seat-map-shell { height: 680px; }
}

#seat-map-shell.is-view-only {
  height: min(68vh, 560px);
}
@media (min-width: 1024px) {
  #seat-map-shell.is-view-only { height: 560px; }
}

#seat-viewport {
  position: absolute;
  inset: 0;
  z-index: 1;
  touch-action: none;
  cursor: grab;
}
#seat-viewport:active { cursor: grabbing; }

/*
 * Mobile page-scroll mode: keep touch-action:none on the map.
 * #seat-map-shell has overflow:hidden — native touch-action:pan-y would try to
 * scroll the shell (nowhere to go) instead of the document. JS window.scrollBy
 * on touchmove (passive:false) scrolls the page, including when the finger is on a seat.
 */
@media (max-width: 1023px) {
  #seat-map-shell.allows-page-scroll-y #seat-viewport,
  #seat-map-shell.allows-page-scroll-y #seat-viewport:active {
    cursor: default;
  }
  #seat-map-shell.allows-page-scroll-y .seat-btn {
    -webkit-tap-highlight-color: transparent;
    cursor: default;
  }
}

#seat-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--canvas-width, 980px);
  height: 980px;
  margin-left: 0;
  transform-origin: 0 0;
  transform: translate(0px, 0px) scale(1);
}

.seat-stage {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 520px;
  height: 90px;
  background: #5B3FF8;
  border-radius: 0 0 100% 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 1rem;
  box-shadow: 0 10px 15px -3px rgba(91, 63, 248, 0.2);
}
.seat-stage span {
  color: #fff;
  font-size: 0.875rem;
  font-weight: 900;
  letter-spacing: 0.35em;
  text-transform: uppercase;
}

.seat-best-zone {
  position: absolute;
  left: 50%;
  top: 100px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(91, 63, 248, 0.7);
  white-space: nowrap;
}

/* Seat hit target — size from tokens, position from --seat-x / --seat-y.
   Use div[role=button] (not <button>) so mobile page scroll works under the finger. */
.seat-btn {
  position: absolute;
  left: var(--seat-x, 0);
  top: var(--seat-y, 0);
  width: var(--seat-size, 26px);
  height: var(--seat-size, 26px);
  margin-left: calc(var(--seat-size, 26px) / -2);
  margin-top: calc(var(--seat-size, 26px) / -2);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--seat-size, 26px) * 0.35);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  box-sizing: border-box;
  padding: 0;
  line-height: 1;
  border: none;
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  color: #6D28D9;
  border: 1.5px solid #A78BFA;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}
.seat-btn:hover { transform: scale(1.12); z-index: 5; }
.seat-btn.is-vip {
  background: #F5C542;
  color: #5B3A00;
  border: 1.5px solid #E0A820;
}
.seat-btn.is-standard {
  background: #fff;
  color: #6D28D9;
  border: 1.5px solid #A78BFA;
}
.seat-btn.is-occupied {
  background: #D1D5DB;
  color: #6B7280;
  border: 1.5px solid #9CA3AF;
  cursor: not-allowed;
  opacity: 0.7;
}
.seat-btn.is-sold {
  background: #D1D5DB;
  color: #6B7280;
  border: 1.5px solid #9CA3AF;
  cursor: not-allowed;
  opacity: 0.7;
  pointer-events: none;
}
.seat-btn.is-selected {
  background: #5B3FF8;
  color: #fff;
  border: 1.5px solid #4C2FE0;
  box-shadow: 0 0 0 3px rgba(91, 63, 248, 0.25);
}
.seat-btn.is-owned {
  background: #5B3FF8;
  color: #fff;
  border: 1.5px solid #4C2FE0;
  box-shadow: 0 0 0 3px rgba(91, 63, 248, 0.25);
  cursor: default;
  pointer-events: none;
  opacity: 1;
}
#seat-map-shell.is-view-only .seat-btn:hover {
  transform: none;
  z-index: auto;
}

.seat-row-label,
.seat-section-label {
  position: absolute;
  left: var(--seat-x, 0);
  top: var(--seat-y, 0);
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-weight: 800;
}
.seat-row-label {
  font-size: 11px;
  color: #9CA3AF;
  letter-spacing: 0.04em;
}
.seat-section-label {
  font-size: 10px;
  color: #6B7280;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

#seat-popup::before {
  content: '';
  position: absolute;
  top: var(--arrow-top, 16px);
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
}
#seat-popup.popup-arrow-left::before {
  left: -6px;
  border-left: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}
#seat-popup.popup-arrow-right::before {
  right: -6px;
  left: auto;
  border-right: 1px solid #e5e7eb;
  border-top: 1px solid #e5e7eb;
}

.session-dropdown { width: 100%; }
.session-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  border: 1px solid #5B3FF8;
  background: #f5f3ff;
  box-shadow: 0 0 0 3px rgba(91, 63, 248, 0.12);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.session-trigger[aria-expanded="true"] .session-chevron {
  transform: rotate(180deg);
}
.session-chevron { transition: transform 0.2s ease; }
.session-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 0.35rem;
  max-height: 280px;
  overflow-y: auto;
}
.session-option {
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 0.75rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}
.session-option:hover { background: #f9fafb; }
.session-option.is-active { background: #f5f3ff; }
.session-option.is-soldout { opacity: 0.72; }

/* Session sold-out: placeholder seats + centered message (no real seat interaction) */
#seat-map-shell.is-session-soldout #seat-canvas {
  display: none;
}

#seat-map-shell.is-session-soldout #seat-soldout-canvas {
  display: flex;
}

#seat-map-shell.is-session-soldout .seat-map-zoom-toolbar,
#seat-map-shell.is-session-soldout #seat-checkout-bar {
  display: none !important;
}

#seat-map-shell.is-session-soldout #seat-viewport {
  overflow: hidden;
  cursor: default;
}

.seat-soldout-canvas[hidden] {
  display: none !important;
}

.session-soldout-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(244, 245, 247, 0.35);
  pointer-events: none;
  direction: rtl;
  unicode-bidi: isolate;
}

.session-soldout-overlay[hidden] {
  display: none !important;
}

.session-soldout-overlay__card {
  pointer-events: none;
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e5e7eb;
  border-radius: 1.25rem;
  padding: 1.35rem 1.5rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  max-width: 22rem;
  width: 100%;
  direction: rtl;
  unicode-bidi: isolate;
}

.session-soldout-overlay__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.6;
}

/* Event held / finished: placeholder seats + centered message */
#seat-map-shell.is-event-held {
  pointer-events: auto;
}

#seat-map-shell.is-event-held #seat-viewport {
  overflow: hidden;
  cursor: default;
}

#seat-map-shell.is-event-held .seat-map-zoom-toolbar,
#seat-map-shell.is-event-held #seat-checkout-bar {
  display: none !important;
}

.event-held-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(244, 245, 247, 0.35);
  pointer-events: none;
  direction: rtl;
  unicode-bidi: isolate;
}

.event-held-overlay__card {
  pointer-events: none;
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e5e7eb;
  border-radius: 1.25rem;
  padding: 1.35rem 1.5rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  max-width: 22rem;
  width: 100%;
  direction: rtl;
  unicode-bidi: isolate;
}

.event-held-overlay__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.6;
}

/* Pre-sale placeholder (Event.sale_opens_at not reached yet) */
#seat-map-shell.is-presale {
  pointer-events: auto;
}

#seat-map-shell.is-presale #seat-viewport {
  overflow: hidden;
}

.seat-presale-canvas {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2.75rem;
  opacity: 0.55;
  filter: blur(1.5px);
  transform: scale(1.02);
  pointer-events: none;
  user-select: none;
}

.seat-presale-canvas .seat-stage {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  margin-bottom: 1.25rem;
  width: min(420px, 70%);
  height: 64px;
}

.seat-presale-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 0 1.5rem 2rem;
}

.seat-presale-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.seat-presale-seat {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid #A78BFA;
  background: #fff;
  flex-shrink: 0;
}

.seat-presale-seat.is-vip {
  border-color: transparent;
  background: #F5C542;
}

.sale-opens-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(244, 245, 247, 0.35);
  pointer-events: none;
  direction: rtl;
  unicode-bidi: isolate;
}

.sale-opens-overlay__card {
  pointer-events: none;
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e5e7eb;
  border-radius: 1.25rem;
  padding: 1.35rem 1.5rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  max-width: 22rem;
  width: 100%;
  direction: rtl;
  unicode-bidi: isolate;
}

.sale-opens-overlay__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.6;
}

.sale-opens-overlay__when {
  margin-top: 0.85rem;
}

.sale-opens-overlay__date {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.4;
  color: #111827;
  direction: rtl;
  unicode-bidi: isolate;
}

.sale-opens-overlay__clock {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #5B3FF8;
}

.sale-opens-overlay__countdown {
  margin: 0.85rem 0 0;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.7;
  color: #5B3FF8;
  direction: rtl;
}

/* Floor switcher (multi-floor halls) */
.floor-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.floor-switcher.hidden {
  display: none;
}

.floor-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.floor-switcher__btn:hover:not(:disabled) {
  background: #f5f3ff;
  color: #5B3FF8;
}

.floor-switcher__btn.is-active {
  background: #5B3FF8;
  color: #fff;
}

.floor-switcher__btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.floor-switcher__count {
  font-size: 0.65rem;
  font-weight: 800;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.floor-switcher__btn.is-active .floor-switcher__count {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

#seat-map-shell.is-floor-loading #seat-viewport {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

#seat-map-shell.is-floor-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.75rem;
  height: 1.75rem;
  margin: -0.875rem 0 0 -0.875rem;
  border: 2.5px solid #c4b5fd;
  border-top-color: #5B3FF8;
  border-radius: 50%;
  animation: seat-floor-spin 0.7s linear infinite;
  z-index: 25;
}

@keyframes seat-floor-spin {
  to { transform: rotate(360deg); }
}

/* Zoom toolbar — centered without Tailwind translate (v4 translate breaks mobile). */
.seat-map-zoom-toolbar {
  position: absolute;
  top: 1rem;
  left: 0;
  right: 0;
  width: max-content;
  max-width: calc(100% - 1.5rem);
  margin-inline: auto;
  z-index: 30;
  pointer-events: auto;
}

/*
 * In-shell checkout bar (desktop + tablet).
 * Explicit width + left/right 0 + margin-inline:auto — never Tailwind translate
 * centering (v4 `translate` shifts the bar off-screen), never left+right with
 * width:auto alone (stretches full shell and looks like a mobile dock).
 */
#seat-checkout-bar.seat-checkout-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1rem;
  width: min(48rem, calc(100% - 2rem));
  max-width: min(48rem, calc(100% - 2rem));
  margin-inline: auto;
  z-index: 40;
  transform: none;
  translate: none;
  --tw-translate-x: 0;
  --tw-translate-y: 0;
  box-sizing: border-box;
}

/*
 * Mobile dock only below lg: JS moves bar to document.body + is-mobile-docked.
 * Media-query guard so a leaked class cannot full-bleed the bar on desktop.
 */
@media (max-width: 1023px) {
  #seat-checkout-bar.seat-checkout-dock.is-mobile-docked,
  #seat-checkout-bar.seat-checkout-dock.is-mobile-docked.is-visible {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    translate: none !important;
    --tw-translate-x: 0 !important;
    --tw-translate-y: 0 !important;
    z-index: 56 !important;
    box-sizing: border-box;
  }

  #seat-checkout-bar.seat-checkout-dock.is-mobile-docked .seat-checkout-dock__inner {
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.22);
  }

  body:has(#seat-checkout-bar.is-mobile-docked.is-visible) {
    padding-bottom: calc(4.75rem + 9.25rem + env(safe-area-inset-bottom, 0px));
  }
}

