/* Server-rendered toasts (shared/_toast + toast_controller.js). The hub is a
   fixed bottom-right column; each .toast animates itself in and out via the
   data-state attribute its controller sets (entering → visible → leaving).
   This file is served raw by propshaft (only the Tailwind entry is
   build-processed), so everything is plain CSS; the explicit margin/button
   resets exist because Tailwind Preflight is not imported yet (see
   app/assets/tailwind/application.css). */

.toast-hub {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  /* Above modal overlays — the old host was popover-promoted to the top
     layer for the same reason. */
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(20rem, calc(100vw - 2rem));
  pointer-events: none;
}

@media (min-width: 640px) {
  .toast-hub {
    bottom: 1.5rem;
    right: 1.5rem;
  }
}

.toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 34px 14px 16px; /* right side leaves room for the close button */
  background: #fff;
  border: 1px solid var(--agent-line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  user-select: none;
  transition: opacity 250ms ease, transform 250ms ease;
}

.toast[data-state="entering"] {
  opacity: 0;
  transform: translateY(16px);
}

.toast[data-state="leaving"] {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
}

.toast p {
  margin: 0;
}

.toast__icon {
  flex: none;
  display: inline-flex;
  margin-top: 1px;
}

.toast__icon svg {
  width: 18px;
  height: 18px;
}

.toast--success .toast__icon { color: #22c55e; }
.toast--error .toast__icon,
.toast--danger .toast__icon { color: #ef4444; }
.toast--info .toast__icon { color: #3b82f6; }
.toast--warning .toast__icon { color: #fb923c; }
.toast--loading .toast__icon { color: #737373; }

.toast--loading .toast__icon svg {
  animation: toast-spin 1s linear infinite;
}

@keyframes toast-spin {
  to { transform: rotate(360deg); }
}

.toast__content {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 6px;
}

.toast__message {
  font-size: 13px;
  font-weight: 500;
  color: #262626;
  overflow-wrap: break-word;
}

.toast__description {
  font-size: 12px;
  color: #525252;
}

.toast__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.toast__close {
  position: absolute;
  top: 9px;
  right: 9px;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px;
  border-radius: 9999px;
  display: inline-flex;
  cursor: pointer;
  color: #a3a3a3;
  transition: background-color 100ms ease-in-out, color 100ms ease-in-out;
}

.toast__close:hover {
  background: #f5f5f5;
  color: #737373;
}

.toast__close svg {
  width: 12px;
  height: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
