/* App toasts — substitui o banner que empurrava a página.
   Container fixo no canto superior direito, sem layout-shift. */
#app-toasts {
  position: fixed;
  top: calc(86px + env(safe-area-inset-top, 0px));
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #191c24;
  color: #f5f5f5;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 4px solid #6c757d;
  padding: 12px 12px 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  overflow: hidden;
  position: relative;
  animation: app-toast-in 0.25s ease-out;
  max-width: 100%;
}

html.light-theme .app-toast,
.light-theme .app-toast,
body.light .app-toast {
  background: #ffffff;
  color: #212529;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.app-toast--success { border-left-color: #00d25b; }
.app-toast--error { border-left-color: #fc424a; }
.app-toast--warning { border-left-color: #ffab00; }
.app-toast--info { border-left-color: #0090e7; }

.app-toast__icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.app-toast--success .app-toast__icon { background: rgba(0, 210, 91, 0.15); color: #00d25b; }
.app-toast--error .app-toast__icon { background: rgba(252, 66, 74, 0.15); color: #fc424a; }
.app-toast--warning .app-toast__icon { background: rgba(255, 171, 0, 0.18); color: #ffab00; }
.app-toast--info .app-toast__icon { background: rgba(0, 144, 231, 0.15); color: #0090e7; }

.app-toast__body { flex: 1 1 auto; min-width: 0; }
.app-toast__title {
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 2px;
}
.app-toast__message { word-break: break-word; white-space: normal; }
.app-toast__message strong { font-weight: 600; }

.app-toast__close {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.app-toast__close:hover { opacity: 1; }

.app-toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  transform-origin: left center;
  animation: app-toast-progress linear forwards;
}
.app-toast--success .app-toast__progress { background: #00d25b; }
.app-toast--error .app-toast__progress { background: #fc424a; }
.app-toast--warning .app-toast__progress { background: #ffab00; }
.app-toast--info .app-toast__progress { background: #0090e7; }

.app-toast.is-leaving {
  animation: app-toast-out 0.22s ease-in forwards;
}

/* Fallback: se o toast ainda estiver inline no content (antes do JS mover),
   não ocupar espaço no fluxo — evita empurrar a página por 1 frame. */
.app-toast:not(#app-toasts .app-toast) {
  position: fixed;
  top: calc(86px + env(safe-area-inset-top, 0px));
  right: 16px;
  z-index: 9999;
  width: min(360px, calc(100vw - 24px));
}

@keyframes app-toast-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes app-toast-out {
  to { transform: translateX(24px); opacity: 0; }
}
@keyframes app-toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media screen and (max-width: 991px) {
  #app-toasts {
    top: calc(78px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    width: auto;
  }
  .app-toast:not(#app-toasts .app-toast) {
    top: calc(78px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-toast { animation: none; }
  .app-toast__progress { display: none; }
}
