/* =========================================================
   TOASTS — Biblioteca Digital
   Componente global de feedback não bloqueante
   ========================================================= */

.toast-container {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 10000;

  width: min(390px, calc(100vw - 32px));

  display: flex;
  flex-direction: column;
  gap: 12px;

  pointer-events: none;
}

/*
 * O seletor mais específico também evita conflito temporário com
 * o toast antigo existente em perfil.css.
 */
.toast-container .toast {
  --toast-accent: #2878b5;
  --toast-soft: #eef6fc;

  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  z-index: auto;

  width: 100%;
  max-width: none;
  min-width: 0;

  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 30px;
  align-items: start;
  gap: 12px;

  padding: 14px 14px 16px;

  background: #ffffff;
  color: #1f2b24;

  border: 1px solid rgba(26, 58, 39, 0.1);
  border-radius: 14px;

  box-shadow:
    0 12px 32px rgba(21, 45, 31, 0.13),
    0 2px 8px rgba(21, 45, 31, 0.06);

  opacity: 1;
  transform: none;
  overflow: hidden;

  pointer-events: auto;

  animation: toast-in 0.25s ease-out both;
}

.toast-container .toast--success {
  --toast-accent: #24734a;
  --toast-soft: #edf8f1;
}

.toast-container .toast--error {
  --toast-accent: #b94343;
  --toast-soft: #fff1f1;
}

.toast-container .toast--warning {
  --toast-accent: #b77908;
  --toast-soft: #fff8e8;
}

.toast-container .toast--info {
  --toast-accent: #2878b5;
  --toast-soft: #eef6fc;
}

.toast__icon {
  width: 40px;
  height: 40px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  background: var(--toast-soft);
  color: var(--toast-accent);

  font-size: 1rem;
  flex-shrink: 0;
}

.toast__content {
  min-width: 0;

  display: flex;
  flex-direction: column;
  gap: 3px;

  padding-top: 1px;
}

.toast__title {
  display: block;

  color: #203128;

  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.25;
}

.toast__message {
  display: block;

  color: #5c6961;

  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.45;

  overflow-wrap: anywhere;
}

.toast__close {
  width: 30px;
  height: 30px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  margin: -3px -3px 0 0;
  padding: 0;

  border: 0;
  border-radius: 9px;

  background: transparent;
  color: #829087;

  font: inherit;
  font-size: 0.9rem;

  cursor: pointer;

  transition:
    background-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.toast__close:hover {
  background: #f2f5f3;
  color: #39483f;
}

.toast__close:active {
  transform: scale(0.94);
}

.toast__close:focus-visible {
  outline: 2px solid var(--toast-accent);
  outline-offset: 2px;
}

.toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;

  width: 100%;
  height: 3px;

  background: var(--toast-accent);

  transform-origin: left center;

  animation: toast-progress var(--toast-duration, 4200ms) linear forwards;
}

.toast__progress[hidden] {
  display: none;
}

.toast-container .toast--closing {
  pointer-events: none;
  animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(24px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateX(22px) scale(0.985);
  }
}

@keyframes toast-progress {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

@media (max-width: 600px) {
  .toast-container {
    top: 14px;
    left: 14px;
    right: 14px;

    width: auto;
  }

  .toast-container .toast {
    grid-template-columns: 38px minmax(0, 1fr) 28px;
    gap: 10px;

    padding: 13px 12px 15px;

    border-radius: 13px;

    animation-name: toast-in-mobile;
  }

  .toast__icon {
    width: 38px;
    height: 38px;
  }

  .toast__title {
    font-size: 0.9rem;
  }

  .toast__message {
    font-size: 0.82rem;
  }

  .toast-container .toast--closing {
    animation-name: toast-out-mobile;
  }
}

@keyframes toast-in-mobile {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out-mobile {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.99);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast-container .toast,
  .toast-container .toast--closing,
  .toast__progress {
    animation-duration: 0.01ms !important;
  }
}
