/**
 * Toast Notification System
 * Based on XelaSphere Design Specifications
 */

/* ==================== */
/* TOAST CONTAINER */
/* ==================== */

.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
  max-width: 420px;
}

@media (max-width: 768px) {
  .toast-container {
    top: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
    max-width: none;
  }
}

/* ==================== */
/* TOAST NOTIFICATION */
/* ==================== */

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  pointer-events: all;
  min-width: 320px;
  max-width: 420px;
  position: relative;
  overflow: hidden;

  /* Animation */
  animation: toast-slide-in var(--duration-slow) var(--ease-smooth);
  transform-origin: top right;
}

.toast.toast-exiting {
  animation: toast-slide-out var(--duration-normal) var(--ease-in) forwards;
}

/* Progress bar */
.toast::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary-500);
  transform-origin: left;
  animation: toast-progress linear;
}

.toast.toast-success::before {
  background: var(--color-success-500);
}

.toast.toast-error::before {
  background: var(--color-error-500);
}

.toast.toast-warning::before {
  background: var(--color-warning-500);
}

.toast.toast-info::before {
  background: var(--color-info-500);
}

/* Pause animation on hover */
.toast:hover::before {
  animation-play-state: paused;
}

/* ==================== */
/* TOAST ANIMATIONS */
/* ==================== */

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

@keyframes toast-slide-out {
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
}

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

/* ==================== */
/* TOAST ICON */
/* ==================== */

.toast__icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: var(--icon-sm);
}

.toast-default .toast__icon {
  color: var(--color-primary-500);
  background: rgba(14, 165, 233, 0.15);
}

.toast-success .toast__icon {
  color: var(--color-success-500);
  background: rgba(34, 197, 94, 0.15);
}

.toast-error .toast__icon {
  color: var(--color-error-500);
  background: rgba(239, 68, 68, 0.15);
}

.toast-warning .toast__icon {
  color: var(--color-warning-500);
  background: rgba(251, 191, 36, 0.15);
}

.toast-info .toast__icon {
  color: var(--color-info-500);
  background: rgba(59, 130, 246, 0.15);
}

/* ==================== */
/* TOAST CONTENT */
/* ==================== */

.toast__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.toast__title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
  line-height: var(--leading-snug);
}

.toast__message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
  line-height: var(--leading-normal);
  word-wrap: break-word;
}

/* ==================== */
/* TOAST ACTION */
/* ==================== */

.toast__action {
  margin-top: var(--space-2);
}

.toast__action-btn {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-primary-500);
  background: transparent;
  border: 1px solid var(--color-primary-500);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-in-out);
}

.toast__action-btn:hover {
  color: var(--text-inverse);
  background: var(--color-primary-500);
}

/* ==================== */
/* TOAST CLOSE BUTTON */
/* ==================== */

.toast__close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-in-out);
  padding: 0;
}

.toast__close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

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

.toast__close i {
  font-size: var(--text-xs);
}

/* ==================== */
/* ACCESSIBILITY */
/* ==================== */

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

  .toast::before {
    animation: none;
  }

  @keyframes toast-slide-in {
    from, to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes toast-slide-out {
    from, to {
      opacity: 0;
    }
  }
}

/* Screen reader announcements */
.toast[role="status"],
.toast[role="alert"] {
  /* Ensure screen readers announce */
}
