/* Overlay */
.modal-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0; /* jawnie zamiast inset — większa kompatybilność */
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  /* Wymuś nowy stacking context niezależny od przodków */
  transform: translateZ(0);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* Na desktop — wyśrodkowany */
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: var(--space-4);
  }
}

/* Panel modala */
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-6);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-lg);
    max-width: 480px;
    transform: scale(.95);
  }
  .modal-overlay.open .modal { transform: scale(1); }
}

.modal-handle {
  width: 40px; height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-5);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-neutral);
  margin-bottom: var(--space-4);
}

.modal-body {
  color: var(--color-neutral);
  margin-bottom: var(--space-6);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  flex-direction: column;
}

@media (min-width: 400px) {
  .modal-actions { flex-direction: row; justify-content: flex-end; }
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  width: calc(100% - var(--space-8));
  max-width: 420px;
}

.toast {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease forwards;
  pointer-events: all;
  color: #fff;
}

.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-danger); }
.toast.info    { background: var(--color-info); }

.toast.out { animation: toast-out .25s ease forwards; }

/* Toast z przyciskiem akcji (toast(msg, type, duration, { action })) — nie tylko
   aktualizacja PWA, każdy przyszły akcyjny toast dostaje ten sam układ za darmo. */
.toast-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

/* Świadomie osobny styl, nie .btn-outline — ten przycisk siedzi na jednolitym
   kolorowym tle toastu (białe obramowanie/tekst), .btn-outline jest liczony
   pod jasne tło kart/banerów i tam wyglądałby źle bez nadpisywania kolorów. */
.toast-with-action .toast-action {
  flex-shrink: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.toast-with-action .toast-action:hover { background: rgba(255, 255, 255, .15); }

.toast-with-action .toast-action:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@keyframes toast-in  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-4px); } }
