/*
 * Kasa nocy „formularz” (inc/Kasa.php – wersja serwera, src/components/kasa/KasaFormularz.tsx – React; te same klasy) –
 * agent N. Wygląd kasy v7 ze strony głównej (components/Checkout.tsx, styles/checkout.css): panel prawie czarny z włosową
 * ramką, etykiety w kroju mono, pola z włosową linią, jasny przycisk główny; plan sali jak nakładka sali v7 (HallMap,
 * rysunek SVG – bez sceny 3D). Do tego ekran K27 (.tk-ekran) i strony powrotu z płatności (.tz – HTML wtyczki).
 */

.tk {
  --tk-pad: clamp(18px, 2.2vw, 32px);
  --tk-tlo: #07080d;

  margin: 0 0 clamp(48px, 8vh, 96px);
  border: 1px solid var(--tg-linia);
  background: var(--tk-tlo);
  scroll-margin-top: calc(var(--header-h, 64px) + 16px);
}

.tk__glowa {
  display: grid;
  gap: 6px;
  padding: 22px var(--tk-pad) 18px;
  border-bottom: 1px solid var(--tg-linia);
}

.tk__kicker,
.tk__legenda,
.tk__etykieta,
.tk__suma-et {
  margin: 0;
  font-family: var(--tg-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tg-fg-2);
}

.tk__tytul {
  margin: 0;
  font-size: clamp(24px, 2.2vw, 32px);
  font-weight: 760;
  font-stretch: 104%;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.tk__noc {
  margin: 0;
  font-family: var(--tg-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--tg-fg-2);
}

.tk__personel {
  margin: 6px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--tg-stal);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- Formularz: bilety, stoliki, dane, stopka ---------- */
.tk__formularz {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    'blad'
    'bilety'
    'stoliki'
    'dane'
    'stopka'
    'po';
}

.tk__formularz > [role='alert'] {
  grid-area: blad;
  margin: 18px var(--tk-pad) 0;
}

.tk__czesc {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 22px var(--tk-pad);
  border: 0;
  border-bottom: 1px solid var(--tg-linia);
  scroll-margin-top: calc(var(--header-h, 64px) + 16px);
}

.tk__czesc--bilety {
  grid-area: bilety;
}

.tk__czesc--stoliki {
  grid-area: stoliki;
}

.tk__czesc--dane {
  grid-area: dane;
}

.tk__legenda {
  float: left;
  width: 100%;
  margin-bottom: 2px;
  padding: 0;
}

.tk__legenda + * {
  clear: both;
}

.tk__nr {
  margin-right: 4px;
  opacity: 0.6;
}

.tk__opc {
  margin-left: 6px;
  font-family: var(--tg-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--tg-fg-2);
}

.tk__cena {
  margin: 0;
  color: var(--tg-fg-2);
  font-size: 14px;
}

.tk__cena b {
  margin-right: 4px;
  color: var(--tg-fg);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tk__promo,
.tk__podpowiedz,
.tk__drobne,
.tk__k1,
.tk__koniec,
.tk__bezjs {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--tg-fg-2);
}

.tk__promo,
.tk__podpowiedz--wazne {
  color: var(--tg-fg);
}

.tk__drobne a,
.tk__podpowiedz a,
.tk__uwaga a {
  color: var(--tg-fg);
}

.tk__bezjs {
  padding: 16px var(--tk-pad) 20px;
}

/* Bez JavaScriptu: „wyczyść formularz” (type="reset") w zdaniu podpowiedzi przy stolikach – wygląda jak odnośnik. */
.tk__wyczysc {
  display: inline;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tg-fg);
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  cursor: pointer;
}

.tk__wyczysc:focus-visible {
  outline: 2px solid var(--tg-stal);
  outline-offset: 3px;
}

/* Uwagi (K28, wyprzedane, telefonicznie) i błędy (err= – role="alert"). */
.tk__uwaga,
.tk__info-stolik:not(:empty),
.tk__notka {
  margin: 0;
  padding-left: 12px;
  border-left: 2px solid var(--tg-stal);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--tg-fg-2);
}

.tk__info-stolik:empty {
  display: none;
}

.tk [role='alert'],
.tk__blad-pola {
  margin: 0;
  padding: 10px 12px;
  border-left: 2px solid var(--tg-fg);
  background: rgba(227, 230, 237, 0.05);
  font-size: 14px;
  line-height: 1.5;
  color: var(--tg-fg);
}

.tk [role='alert']:focus {
  outline: none;
}

.tk__blad-pola {
  padding: 6px 10px;
  font-size: 13px;
}

.tk .active-order-link a {
  color: var(--tg-fg);
  font-weight: 700;
}

/* Pola: ciemne, włosowa ramka, 16 px tekstu (telefon nie powiększa strony przy fokusie). */
.tk__pole {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.tk__wejscie {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--tg-linia-2);
  border-radius: 0;
  background: rgba(227, 230, 237, 0.035);
  color: var(--tg-fg);
  font: inherit;
  font-size: 16px;
  appearance: none;
  transition:
    border-color 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

select.tk__wejscie {
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--tg-fg-2) 50%), linear-gradient(135deg, var(--tg-fg-2) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 21px,
    calc(100% - 15px) 21px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

select.tk__wejscie option {
  background: var(--tk-tlo);
}

.tk__wejscie:hover {
  border-color: rgba(227, 230, 237, 0.32);
}

.tk__wejscie:focus-visible,
.tk__krok:focus-visible,
.tk__przycisk:focus-visible,
.tk__stolik input:focus-visible {
  outline: 2px solid var(--tg-stal);
  outline-offset: 2px;
}

.tk__wejscie:focus-visible {
  border-color: var(--tg-stal);
  background-color: rgba(227, 230, 237, 0.055);
}

.tk__wejscie[aria-invalid='true'] {
  border-color: var(--tg-fg);
}

.tk__wejscie:disabled {
  opacity: 0.45;
}

/* Liczba biletów: − pole + (jak kasa v7). */
.tk__ilosc {
  display: inline-grid;
  grid-template-columns: 48px 72px 48px;
  justify-self: start;
}

.tk__krok {
  min-height: 48px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--tg-linia-2);
  border-radius: 0;
  background: transparent;
  color: var(--tg-fg);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
  transition:
    background-color 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.tk__krok:hover:not(:disabled) {
  border-color: rgba(227, 230, 237, 0.4);
  background: rgba(227, 230, 237, 0.06);
}

.tk__krok:disabled {
  opacity: 0.35;
  cursor: default;
}

.tk__liczba {
  border-inline: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.tk__liczba::-webkit-outer-spin-button,
.tk__liczba::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

/* ---------- Plan sali (React – PlanSali.tsx; bez JS ukryty) ---------- */
.tk__plan {
  position: relative;
  width: 100%;
  aspect-ratio: 1030 / 614;
  border: 1px solid var(--tg-linia);
  background: rgba(227, 230, 237, 0.012);
  overflow: hidden;
}

.tk-plan__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--tg-fg-2);
}

.tk-plan__stolik {
  transition: opacity 0.3s cubic-bezier(0.33, 1, 0.68, 1);
}

.tk-plan__strefa,
.tk-plan__nr,
.tk-plan__notka {
  position: absolute;
  translate: -50% -50%;
  font-family: var(--tg-mono);
  white-space: nowrap;
  pointer-events: none;
}

.tk-plan__strefa {
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(160, 168, 184, 0.85);
}

.tk-plan__strefa--schody {
  translate: -50% -100%;
}

.tk-plan__strefa--cicha {
  color: rgba(144, 151, 166, 0.42);
}

.tk-plan__nr {
  min-width: 18px;
  padding: 1px 4px;
  background: var(--tk-tlo);
  color: var(--tg-fg);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  transition:
    background-color 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.tk-plan__nr[data-ui='wybrany'] {
  background: var(--tg-fg);
  color: var(--tg-ink);
}

.tk-plan__nr[data-ui='w_platnosci'],
.tk-plan__nr[data-ui='sprzedany'] {
  color: rgba(144, 151, 166, 0.7);
}

.tk-plan__nr[data-ui='sprzedany'] {
  text-decoration: line-through;
}

.tk-plan__notka {
  translate: -50% -100%;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--tg-fg-2);
  text-shadow: 0 0 6px var(--tk-tlo);
}

.tk-plan__traf {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.tk-plan__traf:disabled {
  cursor: not-allowed;
}

/* ---------- Lista stolików (dostępny odpowiednik planu; bez JS – wybór jednego stolika) ---------- */
.tk__lista {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tk__stolik label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    'pole nazwa'
    'pole stan';
  column-gap: 12px;
  align-items: center;
  min-height: 52px;
  padding: 8px 12px;
  border: 1px solid var(--tg-linia);
  cursor: pointer;
  transition:
    border-color 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.tk__stolik label:hover {
  border-color: var(--tg-linia-2);
}

.tk__stolik:has(input:checked) label {
  border-color: rgba(227, 230, 237, 0.7);
  background: rgba(227, 230, 237, 0.06);
}

.tk__stolik[data-stan='w_platnosci'] label,
.tk__stolik[data-stan='sprzedany'] label {
  cursor: not-allowed;
  opacity: 0.55;
}

.tk__stolik input {
  grid-area: pole;
  flex: none;
  display: grid;
  place-content: center;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid rgba(227, 230, 237, 0.5);
  border-radius: 0;
  background: transparent;
  cursor: inherit;
  appearance: none;
}

.tk__stolik input::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--tg-fg);
  scale: 0;
  transition: scale 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.tk__stolik input:checked {
  border-color: var(--tg-fg);
}

.tk__stolik input:checked::before {
  scale: 1;
}

.tk__stolik-nr {
  grid-area: nazwa;
  font-size: 14px;
  font-weight: 600;
}

.tk__stolik-stan {
  grid-area: stan;
  font-family: var(--tg-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--tg-fg-2);
}

/* ---------- Stopka: suma, przycisk, K1, koniec sprzedaży ---------- */
.tk__stopka {
  grid-area: stopka;
  display: grid;
  gap: 10px;
  padding: 16px var(--tk-pad) 12px;
  background: var(--tk-tlo);
}

.tk__po {
  grid-area: po;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 0 var(--tk-pad) 20px;
}

.tk__suma {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 0;
}

.tk__kwota {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.tk__notka-sumy {
  margin: -4px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--tg-fg-2);
}

.tk__przycisk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 0 22px;
  border: 1px solid var(--tg-fg);
  border-radius: 0;
  background: var(--tg-fg);
  color: var(--tg-ink);
  font-family: var(--tg-display);
  font-size: 14px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    scale 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.tk__przycisk:hover:not(:disabled) {
  border-color: #fff;
  background: #fff;
}

.tk__przycisk:active:not(:disabled) {
  scale: 0.98;
}

.tk__przycisk:disabled,
.tk__przycisk[aria-busy='true'] {
  opacity: 0.55;
  cursor: progress;
}

.tk__przycisk--linia {
  border-color: var(--tg-linia-2);
  background: transparent;
  color: var(--tg-fg);
}

.tk__przycisk--linia:hover:not(:disabled) {
  border-color: rgba(227, 230, 237, 0.5);
  background: rgba(227, 230, 237, 0.05);
}

/* Telefon: stopka z kwotą i przyciskiem przyklejona do dołu ekranu, gdy formularz jest w kadrze. */
@media (max-width: 899px) {
  /* Kwota i przycisk w jednym rzędzie, przyklejone do dołu ekranu, gdy formularz jest w kadrze; K1 i koniec sprzedaży –
     tuż pod przyciskiem w jego miejscu docelowym. */
  .tk__stopka {
    position: sticky;
    bottom: 0;
    z-index: 4;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 16px;
    padding: 10px var(--tk-pad) calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--tg-linia-2);
    box-shadow: 0 -24px 40px rgba(3, 4, 8, 0.55);
  }

  .tk__suma {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .tk__kwota {
    font-size: 22px;
  }

  .tk__stopka .tk__przycisk {
    min-height: 50px;
    padding: 0 14px;
    font-size: 13px;
    letter-spacing: 0.035em;
  }

  .tk__po {
    padding-top: 12px;
  }

  .tk__k1,
  .tk__koniec {
    font-size: 11.5px;
    line-height: 1.45;
  }

  .tk__lista {
    grid-template-columns: minmax(0, 1fr);
  }

  .tk-plan__strefa {
    font-size: 8.5px;
    letter-spacing: 0.18em;
  }

  .tk-plan__nr {
    min-width: 14px;
    padding: 0 3px;
    font-size: 8.5px;
  }

  .tk-plan__notka {
    font-size: 8px;
  }
}

/* Komputer: bilety, dane i stopka po lewej, sala po prawej (jak kasa v7: panel i sala obok siebie). */
@media (min-width: 900px) {
  .tk__formularz--sala {
    grid-template-columns: minmax(340px, 5fr) minmax(0, 7fr);
    grid-template-rows: auto auto auto auto 1fr;
    grid-template-areas:
      'blad blad'
      'bilety stoliki'
      'dane stoliki'
      'stopka stoliki'
      'po stoliki';
  }

  .tk__formularz--sala .tk__czesc--stoliki {
    border-left: 1px solid var(--tg-linia);
  }

  .tk__formularz:not(.tk__formularz--sala) {
    max-width: 640px;
  }

}

/* Kasa bez formularza: sprzedaż zakończona, wyłączona, wyprzedana. */
.tk__stan {
  padding: 22px var(--tk-pad) 26px;
}

.tk__stan-tytul {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}

.tk__stan-tekst,
.tk__stan-dalej {
  max-width: 64ch;
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
}

.tk__stan-dalej {
  margin-top: 8px;
  color: var(--tg-fg-2);
}

.tk__stan > [role='alert'] {
  margin-bottom: 14px;
}

/* ---------- Ekran K27 (Kasa::ekranPowtorki – pełna strona z odpowiedzi na zamówienie) ---------- */
.tk-ekran .tk-ekran__ramka {
  max-width: 760px;
  min-height: 100vh;
  padding-top: 24px;
  padding-bottom: 64px;
}

.tk-ekran__znak {
  margin: 0 0 clamp(48px, 10vh, 96px);
}

.tk-ekran__znak a {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  text-decoration: none;
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: 0.2em;
}

.tk-ekran__svg {
  width: 30px;
  height: 25px;
}

.tk-ekran__tytul {
  margin: 8px 0 16px;
  font-size: clamp(32px, 4.6vw, 52px);
  font-weight: 800;
  font-stretch: 112%;
  line-height: 1.04;
}

.tk-ekran__tekst {
  max-width: 60ch;
  margin: 0 0 28px;
  font-size: 17px;
  line-height: 1.55;
}

.tk-ekran__akcje {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 20px;
}

.tk-ekran__akcje .tk__przycisk {
  width: auto;
}

.tk-ekran__wroc {
  font-family: var(--tg-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Strony powrotu z płatności (szablony/zamowienie.php – HTML wtyczki z własnymi stylami w atrybutach) ---------- */
.tz {
  max-width: 900px;
  margin: 0 0 clamp(32px, 5vh, 48px);
  line-height: 1.6;
}

.tz .thanks {
  display: block !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 0 24px !important;
}

.tz .thanks > div {
  width: auto !important;
  max-width: 72ch;
  text-align: left !important;
}

.tz .ticket-separator {
  min-height: 0 !important;
  height: 1px;
  margin: 20px 0 !important;
  background-color: var(--tg-linia-2) !important;
}

.tz h2,
.tz h3 {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 34px);
  font-weight: 760;
  font-stretch: 106%;
  line-height: 1.12;
}

.tz .order-code {
  font-family: var(--tg-mono);
  font-weight: 500;
  letter-spacing: 0.14em;
}

.tz h2 .order-code {
  display: inline-block;
  font-size: clamp(30px, 3.6vw, 46px);
  letter-spacing: 0.18em;
}

.tz .payment-message {
  max-width: 68ch;
  padding: 0 !important;
  text-align: left !important;
  color: var(--tg-fg-2);
}

.tz .payment-message a {
  color: var(--tg-fg);
}

.tz .imp {
  color: var(--tg-fg) !important;
  font-weight: 600 !important;
}

.tz .ticket-play {
  margin: 20px 0 0 !important;
  text-align: left !important;
  font-family: var(--tg-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tz .payment-action-notice {
  max-width: 72ch !important;
  margin: 0 0 24px !important;
  padding: 10px 14px !important;
  border: 0 !important;
  border-left: 2px solid var(--tg-fg) !important;
  background: rgba(227, 230, 237, 0.05);
}

.tz .payment-actions {
  gap: 10px !important;
  margin-top: 24px !important;
  padding: 0 !important;
}

.tz .payment-actions form {
  margin: 0;
}

.tz .payment-actions button {
  min-height: 52px;
  padding: 10px 22px;
  border: 1px solid var(--tg-linia-2);
  border-radius: 0;
  background: transparent;
  color: var(--tg-fg);
  font-family: var(--tg-display);
  font-size: 14px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.tz .payment-actions #pay-again-button {
  border-color: var(--tg-fg);
  background: var(--tg-fg);
  color: var(--tg-ink);
}

.tz .payment-actions button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.tz .payment-actions button:focus-visible {
  outline: 2px solid var(--tg-stal);
  outline-offset: 2px;
}

.tz__dalej {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 0 0 clamp(32px, 6vh, 64px);
  padding-top: 14px;
  border-top: 1px solid var(--tg-linia);
  font-family: var(--tg-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  .tk__wejscie,
  .tk__krok,
  .tk__przycisk,
  .tk__stolik label,
  .tk__stolik input::before,
  .tk-plan__stolik,
  .tk-plan__nr {
    transition: none;
  }
}
