const VARIANTS = {
  success: "border-accent/40 bg-[#1e2739]/95 text-accent-bright",
  error: "border-red-400/40 bg-red-950/90 text-red-50",
  info: "border-accent/40 bg-brand-100/95 text-slate-100",
};

export function showToast(message, variant = "info") {
  const root = document.getElementById("toast-root");
  if (!root || !message) return;

  const wrap = document.createElement("div");
  wrap.setAttribute("role", "status");
  wrap.className = `toast-item pointer-events-auto max-w-sm rounded-xl border px-4 py-3 text-sm font-medium shadow-panel backdrop-blur-md ${VARIANTS[variant] || VARIANTS.info}`;

  const text = document.createElement("p");
  text.className = "leading-snug";
  text.textContent = message;
  wrap.appendChild(text);

  root.appendChild(wrap);
  requestAnimationFrame(() => wrap.classList.add("toast-item--in"));

  const hide = () => {
    wrap.classList.remove("toast-item--in");
    wrap.addEventListener(
      "transitionend",
      () => wrap.remove(),
      { once: true }
    );
  };
  setTimeout(hide, 3600);
}
