/* LevelUp V54 — Płatności klienta
   Priorytet: „Przedłuż współpracę” jest zawsze pełną, naturalną sekcją.
   Historia zajmuje resztę lewej kolumny i to ona przewija się w razie potrzeby.
   Prawa automatyzacja nie może wychodzić poza kartę. */

.lu-v54-payments-grid,
.lu-v54-payments-left,
.lu-v54-payments-right,
.lu-v54-extend-card,
.lu-v54-history-card,
.lu-v54-cooperation-card,
.lu-v54-automation-card {
  box-sizing: border-box !important;
  min-width: 0 !important;
}

/* Główny układ płatności zachowuje dwie kolumny, ale obie mogą się poprawnie kurczyć. */
.lu-v54-payments-grid {
  min-height: 0 !important;
  align-items: stretch !important;
  overflow: hidden !important;
}

/* LEWA KOLUMNA — najpierw współpraca, później historia. */
.lu-v54-payments-left {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  min-height: 0 !important;
  height: 100% !important;
  overflow: hidden !important;
}

.lu-v54-extend-card {
  order: -10 !important;
  flex: 0 0 auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  contain: none !important;
}

/* Kasujemy stare ograniczenia wysokości wewnątrz rozszerzonej sekcji. */
.lu-v54-extend-card > * {
  max-height: none !important;
}

.lu-v54-extend-card [style*="max-height"] {
  max-height: none !important;
}

.lu-v54-extend-card [style*="overflow"] {
  overflow: visible !important;
}

.lu-v54-history-card {
  flex: 1 1 auto !important;
  min-height: 220px !important;
  max-height: none !important;
  overflow: hidden !important;
}

.lu-v54-history-scroll {
  min-height: 0 !important;
  max-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable !important;
}

/* PRAWA KOLUMNA — kontrolowany scroll kolumny, ale same karty mają naturalną wysokość. */
.lu-v54-payments-right {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  min-height: 0 !important;
  height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scrollbar-gutter: stable !important;
  padding-right: 4px !important;
  padding-bottom: 10px !important;
}

.lu-v54-cooperation-card,
.lu-v54-automation-card {
  flex: 0 0 auto !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: none !important;
}

.lu-v54-automation-card {
  overflow: hidden !important;
}

.lu-v54-automation-card > *,
.lu-v54-automation-card form,
.lu-v54-automation-card label,
.lu-v54-automation-card div {
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.lu-v54-automation-card input,
.lu-v54-automation-card select,
.lu-v54-automation-card textarea {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

.lu-v54-automation-card textarea {
  min-height: 76px !important;
  resize: vertical !important;
  overflow-wrap: anywhere !important;
}

/* Pola 2-kolumnowe nie mogą wypychać prawego panelu. */
.lu-v54-automation-card [style*="grid-template-columns"] {
  min-width: 0 !important;
}

@media (max-width: 1100px) {
  .lu-v54-payments-grid {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  .lu-v54-payments-left,
  .lu-v54-payments-right {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .lu-v54-history-card {
    min-height: 320px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lu-v54-extend-card,
  .lu-v54-history-card,
  .lu-v54-automation-card {
    scroll-behavior: auto !important;
  }
}
