/**
 * Toast Component Styles
 * Messages flash modernes avec animations fluides et support dark mode
 */

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

.toast-container {
  position: fixed;
  top: var(--space-8);
  right: var(--space-8);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 420px;
  width: calc(100vw - 2rem);
  pointer-events: none;
}

/* ===== TOAST BASE STYLES ===== */

.toast-notification {
  pointer-events: all;
  background-color: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  position: relative;
  overflow: hidden;
  animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all var(--transition-base);
}

.toast-notification:hover {
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

/* Animation d'entrée */
@keyframes toast-slide-in {
  from {
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Animation de sortie */
.toast-notification.hiding {
  animation: toast-slide-out 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(calc(100% + 2rem));
    opacity: 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: 14px;
  font-weight: var(--font-weight-semibold);
}

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

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

.toast-message {
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  line-height: 1.5;
  word-wrap: break-word;
}

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

.toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
  font-size: 20px;
  line-height: 1;
  opacity: 0.7;
}

.toast-close:hover {
  background-color: var(--color-bg-hover);
  color: var(--color-text-primary);
  opacity: 1;
}

.toast-close:active {
  transform: scale(0.95);
}

/* ===== TOAST VARIANTS ===== */

/* Success */
.toast-notification.toast-success {
  border-left: 4px solid var(--color-success);
}

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

.toast-notification.toast-success .toast-icon::before {
  content: "✓";
}

/* Info */
.toast-notification.toast-info {
  border-left: 4px solid var(--color-info);
}

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

.toast-notification.toast-info .toast-icon::before {
  content: "ℹ";
}

/* Warning */
.toast-notification.toast-warning {
  border-left: 4px solid var(--color-warning);
}

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

.toast-notification.toast-warning .toast-icon::before {
  content: "⚠";
}

/* Danger/Error */
.toast-notification.toast-danger,
.toast-notification.toast-error {
  border-left: 4px solid var(--color-danger);
}

.toast-notification.toast-danger .toast-icon,
.toast-notification.toast-error .toast-icon {
  background-color: var(--color-danger-light);
  color: var(--color-danger);
}

.toast-notification.toast-danger .toast-icon::before,
.toast-notification.toast-error .toast-icon::before {
  content: "✕";
}

/* ===== TOAST PROGRESS BAR ===== */

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background-color: currentColor;
  opacity: 0.3;
  transform-origin: left;
  animation: toast-progress 5s linear forwards;
}

.toast-notification.toast-success .toast-progress {
  color: var(--color-success);
}

.toast-notification.toast-info .toast-progress {
  color: var(--color-info);
}

/* Les toasts warning, danger et error n'ont pas de progress bar (pas d'auto-dismiss) */

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

/* Pause l'animation au hover */
.toast-notification:hover .toast-progress {
  animation-play-state: paused;
}

/* Masquer la barre de progression pour les toasts danger et warning (pas d'auto-dismiss) */
.toast-notification.toast-danger .toast-progress,
.toast-notification.toast-error .toast-progress,
.toast-notification.toast-warning .toast-progress {
  display: none;
}

/* ===== RESPONSIVE ===== */

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

  .toast-notification {
    padding: var(--space-3);
    gap: var(--space-2);
  }

  .toast-icon {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }

  .toast-message {
    font-size: var(--font-size-sm);
  }
}

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

  .toast-notification {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
  }
}

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

/* Focus visible pour la navigation au clavier */
.toast-close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Reduced motion pour les utilisateurs qui préfèrent */
@media (prefers-reduced-motion: reduce) {
  .toast-notification {
    animation-duration: 0.1s;
  }

  .toast-notification.hiding {
    animation-duration: 0.1s;
  }

  .toast-notification:hover {
    transform: none;
  }
}
