/* Toast Notification System v2 — UI Comprehensive Refactor
 * Requires: tokens.css, spacing.css, typography.css
 * Per design.md § 7.4: bottom-right desktop, top-center mobile.
 * z-index: 9999 (above modals at 1050, below confirm-dialog at 10000).
 */

/* ── Container ─────────────────────────────────────────────────────────── */
#toast-root {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 9999;
  pointer-events: none;
  max-width: 380px;
}

/* ── Base toast ────────────────────────────────────────────────────────── */
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  pointer-events: auto;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--color-brand-500);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-md);
  font-size: var(--font-sm);
  line-height: var(--line-base);
  color: var(--text-primary);
  animation: toast-slide-in-right 0.25s ease-out forwards;
}

/* ── Icon ──────────────────────────────────────────────────────────────── */
.toast__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--color-brand-500);
}

/* ── Message ───────────────────────────────────────────────────────────── */
.toast__message {
  flex: 1;
  min-width: 0;
}

/* ── Close button ──────────────────────────────────────────────────────── */
.toast__close {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  transition: color 0.15s ease;
}

.toast__close:hover { color: var(--text-primary); }
.toast__close svg   { width: 14px; height: 14px; }

/* ── Variants ──────────────────────────────────────────────────────────── */
.toast--success { border-left-color: var(--color-success-500); }
.toast--success .toast__icon { color: var(--color-success-500); }

.toast--warn    { border-left-color: var(--color-warning-500); }
.toast--warn    .toast__icon { color: var(--color-warning-500); }

.toast--error   { border-left-color: var(--color-error-500); }
.toast--error   .toast__icon { color: var(--color-error-500); }

/* ── Leaving state ─────────────────────────────────────────────────────── */
.toast--leaving {
  animation: toast-slide-out-right 0.25s ease-in forwards;
}

/* ── Animations: desktop (slide from right) ────────────────────────────── */
@keyframes toast-slide-in-right {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0);    }
}

@keyframes toast-slide-out-right {
  from { opacity: 1; transform: translateX(0);    }
  to   { opacity: 0; transform: translateX(100%); }
}

/* ── Mobile: top-center, slide from top ────────────────────────────────── */
@media (max-width: 768px) {
  #toast-root {
    bottom: auto;
    top: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
    max-width: none;
  }

  .toast {
    animation: toast-slide-in-top 0.25s ease-out forwards;
  }

  .toast--leaving {
    animation: toast-slide-out-top 0.25s ease-in forwards;
  }

  @keyframes toast-slide-in-top {
    from { opacity: 0; transform: translateY(-100%); }
    to   { opacity: 1; transform: translateY(0);     }
  }

  @keyframes toast-slide-out-top {
    from { opacity: 1; transform: translateY(0);     }
    to   { opacity: 0; transform: translateY(-100%); }
  }
}
