/**
 * RADEXEL Design System - Enhanced Toast Notification
 *
 * Queue-based toast system with:
 * - 4 variants: success, error, warning, info
 * - ARIA live region support
 * - Slide-in animation from bottom-right
 * - Auto-dismiss progress bar
 * - Stacking with gap
 */

/* ==========================================================================
   Toast Container (Bottom-Right)
   ========================================================================== */

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

/* ARIA live region (invisible, read by screen readers) */
.toast-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ==========================================================================
   Individual Toast
   ========================================================================== */

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  max-width: 100%;

  /* Entrance animation */
  animation: toastSlideIn var(--duration-slow) var(--ease-out) forwards;
}

/* Exit animation class - applied before removal */
.toast.dismissing {
  animation: toastSlideOut var(--duration-base) var(--ease-in) forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%) translateY(0);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}


/* ==========================================================================
   Toast Icon
   ========================================================================== */

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

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


/* ==========================================================================
   Toast Content
   ========================================================================== */

.toast__content {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.toast__message {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-base);
}

.toast__action {
  display: inline-block;
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--rdx-blue);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.toast__action:hover {
  color: var(--rdx-blue-dark);
  text-decoration: underline;
}


/* ==========================================================================
   Toast Close Button
   ========================================================================== */

.toast__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background-color var(--duration-fast) var(--ease-default),
    color var(--duration-fast) var(--ease-default);
}

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

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


/* ==========================================================================
   Auto-Dismiss Progress Bar
   ========================================================================== */

.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  animation: toastProgress var(--toast-duration, 5s) linear forwards;
}

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


/* ==========================================================================
   Variant: Success
   ========================================================================== */

.toast--success {
  border-left: 3px solid var(--color-success);
}

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

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


/* ==========================================================================
   Variant: Error / Danger
   ========================================================================== */

.toast--error {
  border-left: 3px solid var(--color-danger);
}

.toast--error .toast__icon {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.toast--error .toast__progress {
  background: var(--color-danger);
}


/* ==========================================================================
   Variant: Warning
   ========================================================================== */

.toast--warning {
  border-left: 3px solid var(--color-warning);
}

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

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


/* ==========================================================================
   Variant: Info
   ========================================================================== */

.toast--info {
  border-left: 3px solid var(--color-info);
}

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

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


/* ==========================================================================
   Simple Toast (Backward compat - no icon, solid bg)
   ========================================================================== */

.toast.toast--simple {
  padding: var(--space-3) var(--space-4);
  border-left: none;
}

.toast--simple.success {
  background: var(--color-success);
  color: var(--color-text-inverse);
  border: none;
}

.toast--simple.error {
  background: var(--color-danger);
  color: var(--color-text-inverse);
  border: none;
}

.toast--simple.warning {
  background: var(--color-warning);
  color: #1A1A2E;
  border: none;
}

.toast--simple.info {
  background: var(--rdx-blue);
  color: var(--color-text-inverse);
  border: none;
}

.toast--simple .toast__close {
  color: inherit;
  opacity: 0.7;
}

.toast--simple .toast__close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}


/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: fadeIn var(--duration-fast) var(--ease-out) forwards;
  }

  .toast.dismissing {
    animation: fadeOut var(--duration-fast) var(--ease-in) forwards;
  }

  .toast__progress {
    animation: none;
    width: 0;
  }
}
