/* ═══════════════════════════════════════════════════════════════════════════
   Toast Notifications System V2
   Design moderne avec glass morphism et animations fluides
   Style cohérent avec LibrarySection
   ═══════════════════════════════════════════════════════════════════════════ */

/* Container */
.toast-container {
  position: fixed;
  top: 70px;
  right: var(--space-4);
  z-index: var(--z-toast, 9999);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 320px;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Toast Base Style - Modern Glass Design
   ═══════════════════════════════════════════════════════════════════════════ */

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 14px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.toast:hover {
  transform: translateX(-4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Progress Bar - Auto-dismiss indicator */
.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--toast-color);
  animation: toast-progress var(--toast-duration, 2.5s) linear forwards;
  opacity: 0.5;
}

/* Different durations per type */
.toast.success::after { --toast-duration: 2.5s; }
.toast.info::after { --toast-duration: 2.5s; }
.toast.warning::after { --toast-duration: 3.5s; }
.toast.error::after { --toast-duration: 5s; }

@keyframes toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Toast Types - Avec couleurs et effets spécifiques
   ═══════════════════════════════════════════════════════════════════════════ */

/* Success Toast */
.toast.success {
  --toast-color: #10B981;
  --toast-color-light: #34D399;
  --toast-color-glow: rgba(16, 185, 129, 0.3);
  border-color: rgba(16, 185, 129, 0.25);
  background: linear-gradient(135deg,
    rgba(16, 185, 129, 0.12),
    var(--glass-bg) 50%
  );
}

.toast.success:hover {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(16, 185, 129, 0.15),
    0 0 30px var(--toast-color-glow);
}

.toast.success .toast-icon-wrapper {
  background: linear-gradient(135deg, #10B981, #059669);
  box-shadow:
    0 4px 12px rgba(16, 185, 129, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Error Toast */
.toast.error {
  --toast-color: #EF4444;
  --toast-color-light: #F87171;
  --toast-color-glow: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.25);
  background: linear-gradient(135deg,
    rgba(239, 68, 68, 0.12),
    var(--glass-bg) 50%
  );
}

.toast.error:hover {
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(239, 68, 68, 0.15),
    0 0 30px var(--toast-color-glow);
}

.toast.error .toast-icon-wrapper {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  box-shadow:
    0 4px 12px rgba(239, 68, 68, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.toast.error::after {
  animation-duration: 6s;
}

/* Warning Toast */
.toast.warning {
  --toast-color: #F59E0B;
  --toast-color-light: #FBBF24;
  --toast-color-glow: rgba(245, 158, 11, 0.3);
  border-color: rgba(245, 158, 11, 0.25);
  background: linear-gradient(135deg,
    rgba(245, 158, 11, 0.12),
    var(--glass-bg) 50%
  );
}

.toast.warning:hover {
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(245, 158, 11, 0.15),
    0 0 30px var(--toast-color-glow);
}

.toast.warning .toast-icon-wrapper {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  box-shadow:
    0 4px 12px rgba(245, 158, 11, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Info Toast */
.toast.info {
  --toast-color: #8B5CF6;
  --toast-color-light: #A78BFA;
  --toast-color-glow: rgba(139, 92, 246, 0.3);
  border-color: rgba(139, 92, 246, 0.25);
  background: linear-gradient(135deg,
    rgba(139, 92, 246, 0.12),
    var(--glass-bg) 50%
  );
}

.toast.info:hover {
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(139, 92, 246, 0.15),
    0 0 30px var(--toast-color-glow);
}

.toast.info .toast-icon-wrapper {
  background: linear-gradient(135deg, #8B5CF6, #7C3AED);
  box-shadow:
    0 4px 12px rgba(139, 92, 246, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Toast Icon - Modern circular badge
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-icon {
  flex-shrink: 0;
}

.toast-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: white;
  flex-shrink: 0;
}

.toast-icon svg {
  width: 14px;
  height: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Toast Content - Typography moderne
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* When no title, center message */
.toast-content:not(:has(.toast-title)) .toast-message {
  font-size: 0.8rem;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Toast Close Button - Modern hover effect
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  opacity: 0.4;
  margin-left: auto;
}

.toast:hover .toast-close {
  opacity: 0.8;
}

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

.toast-close svg {
  width: 10px;
  height: 10px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Animations - Entrees/Sorties sophistiquees
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-enter-active {
  animation: toast-slide-in 0.25s ease-out;
}

.toast-leave-active {
  animation: toast-slide-out 0.2s ease-in forwards;
}

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

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

.toast-move {
  transition: transform 0.25s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Stacking - Keep simple
   ═══════════════════════════════════════════════════════════════════════════ */

.toast:nth-child(n+4) {
  opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .toast-container {
    /* Keep at TOP on mobile - above sidebar */
    top: 70px;
    bottom: auto;
    left: var(--space-3);
    right: var(--space-3);
    max-width: none;
    z-index: 1200; /* Above sidebar (1000) and ActionBar (1100) */
  }

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

  .toast-icon-wrapper {
    width: 32px;
    height: 32px;
  }

  .toast-icon svg {
    width: 16px;
    height: 16px;
  }

  .toast-title {
    font-size: 0.85rem;
  }

  .toast-message {
    font-size: 0.8rem;
  }

  .toast-close {
    opacity: 1;
    transform: scale(1);
  }

  /* Slide from top on mobile */
  @keyframes toast-slide-in {
    0% {
      opacity: 0;
      transform: translateY(-100%) scale(0.9);
    }
    100% {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  @keyframes toast-slide-out {
    0% {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
    100% {
      opacity: 0;
      transform: translateY(-50%) scale(0.9);
    }
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Light Mode Adjustments
   ═══════════════════════════════════════════════════════════════════════════ */

:root:not(.dark-mode) .toast {
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.08),
    0 8px 32px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

:root:not(.dark-mode) .toast:hover {
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 16px 48px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

:root:not(.dark-mode) .toast-close {
  background: rgba(0, 0, 0, 0.03);
}

:root:not(.dark-mode) .toast-close:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Confirm Toast - With action buttons
   ═══════════════════════════════════════════════════════════════════════════ */

.toast.confirm {
  --toast-color: #F59E0B;
  --toast-color-light: #FBBF24;
  --toast-color-glow: rgba(245, 158, 11, 0.3);
  border-color: rgba(245, 158, 11, 0.25);
  background: linear-gradient(135deg,
    rgba(245, 158, 11, 0.12),
    var(--glass-bg) 50%
  );
  cursor: default; /* No click-to-dismiss */
  max-width: 360px;
}

.toast.confirm:hover {
  border-color: rgba(245, 158, 11, 0.4);
  transform: none; /* Disable hover slide */
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(245, 158, 11, 0.15),
    0 0 30px var(--toast-color-glow);
}

.toast.confirm .toast-icon-wrapper {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  box-shadow:
    0 4px 12px rgba(245, 158, 11, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* No auto-dismiss bar for confirm toasts */
.toast.confirm::after {
  display: none;
}

/* Toast has actions - prevent click-to-dismiss */
.toast.has-actions {
  cursor: default;
}

.toast.has-actions:hover {
  transform: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Toast Action Buttons
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.toast-action-btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

/* Primary action button */
.toast-action-btn.primary {
  background: linear-gradient(135deg, #8B5CF6, #7C3AED);
  color: white;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.toast-action-btn.primary:hover {
  background: linear-gradient(135deg, #7C3AED, #6D28D9);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

/* Secondary/default action button */
.toast-action-btn.secondary,
.toast-action-btn:not(.primary):not(.danger) {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.toast-action-btn.secondary:hover,
.toast-action-btn:not(.primary):not(.danger):hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

/* Danger action button */
.toast-action-btn.danger {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.toast-action-btn.danger:hover {
  background: linear-gradient(135deg, #DC2626, #B91C1C);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}
