/**
 * Toast 通知（21st.dev / Sonner 风格，右下角堆叠）
 * @author Telegram @okgeceo
 */

.ok-toast-container {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  width: min(calc(100vw - var(--space-8)), 22rem);
  pointer-events: none;
}

.ok-toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 3rem;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--popover);
  color: var(--popover-foreground);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: ok-toast-in var(--duration-normal) var(--ease-snappy) both;
}

.ok-toast.is-leaving {
  animation: ok-toast-out var(--duration-normal) var(--ease-snappy) forwards;
}

.ok-toast__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  color: var(--muted-foreground);
  background: color-mix(in oklch, var(--muted) 70%, transparent);
}

.ok-toast__icon svg {
  width: 1rem;
  height: 1rem;
}

.ok-toast__message {
  min-width: 0;
  word-break: break-word;
}

.ok-toast__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.ok-toast__close:hover {
  color: var(--foreground);
  background: color-mix(in oklch, var(--muted) 55%, transparent);
}

.ok-toast__close svg {
  width: 0.875rem;
  height: 0.875rem;
}

.ok-toast--success .ok-toast__icon {
  color: var(--success);
}

.ok-toast--error .ok-toast__icon {
  color: var(--destructive);
}

.ok-toast--warning .ok-toast__icon {
  color: var(--warning);
}

.ok-toast--info .ok-toast__icon {
  color: var(--info);
}

@keyframes ok-toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ok-toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@media (max-width: 767px) {
  .ok-toast-container {
    right: var(--space-3);
    bottom: var(--space-3);
    width: min(calc(100vw - var(--space-6)), 22rem);
  }
}

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

  .ok-toast.is-leaving {
    animation: none;
    opacity: 0;
  }
}
