/* ==========================================================================
   FICHES INTERVENTION - Toast Notifications
   Non-intrusive feedback system
   Style: Industrial Precision
   ========================================================================== */

/* -------------------------------------------------------------------------
   TOAST CONTAINER
   ------------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-4) + var(--safe-area-inset-top));
  left: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

@media (min-width: 640px) {
  .toast-container {
    left: auto;
    right: var(--space-6);
    max-width: 420px;
  }
}

/* -------------------------------------------------------------------------
   TOAST BASE
   ------------------------------------------------------------------------- */

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--color-slate-400);
  pointer-events: auto;
  animation: toastSlideIn var(--duration-300) var(--ease-spring);
  transform-origin: top center;
  position: relative;
  overflow: hidden;
}

/* Subtle top glow based on type */
.toast::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-slate-300);
}

.toast.is-leaving {
  animation: toastSlideOut var(--duration-200) var(--ease-in) forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-24px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-16px) scale(0.95);
  }
}

/* -------------------------------------------------------------------------
   TOAST VARIANTS
   ------------------------------------------------------------------------- */

.toast-success {
  border-left-color: var(--color-success);
  background: linear-gradient(135deg, white 0%, var(--color-success-50) 100%);
}

.toast-success::before {
  background: var(--gradient-accent);
  opacity: 0.3;
}

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

.toast-error {
  border-left-color: var(--color-error);
  background: linear-gradient(135deg, white 0%, var(--color-error-50) 100%);
}

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

.toast-error .toast-icon {
  color: var(--color-error);
  background: var(--color-error-100);
}

.toast-warning {
  border-left-color: var(--color-warning);
  background: linear-gradient(135deg, white 0%, var(--color-warning-50) 100%);
}

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

.toast-warning .toast-icon {
  color: var(--color-warning-dark);
  background: var(--color-warning-100);
}

.toast-info {
  border-left-color: var(--color-info);
  background: linear-gradient(135deg, white 0%, var(--color-info-50) 100%);
}

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

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

/* -------------------------------------------------------------------------
   TOAST PARTS
   ------------------------------------------------------------------------- */

.toast-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.toast-content {
  flex: 1;
  min-width: 0;
  padding-top: var(--space-1);
}

.toast-title {
  font-family: var(--font-display);
  font-weight: var(--font-semibold);
  color: var(--color-slate-900);
  margin-bottom: var(--space-1);
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--color-slate-600);
  line-height: var(--leading-relaxed);
}

.toast-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-slate-400);
  border-radius: var(--radius-lg);
  transition: all var(--duration-150) var(--ease-out);
  flex-shrink: 0;
  margin: calc(var(--space-1) * -1);
}

.toast-close:hover {
  background: var(--color-slate-100);
  color: var(--color-slate-700);
}

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

/* -------------------------------------------------------------------------
   TOAST PROGRESS BAR (auto-dismiss indicator)
   ------------------------------------------------------------------------- */

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-slate-100);
  overflow: hidden;
}

.toast-progress-bar {
  height: 100%;
  background: var(--color-primary);
  animation: toastProgress 5s linear forwards;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

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

.toast-error .toast-progress-bar {
  background: var(--color-error);
}

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

@keyframes toastProgress {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

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

/* -------------------------------------------------------------------------
   TOAST WITH ACTION
   ------------------------------------------------------------------------- */

.toast-action {
  margin-top: var(--space-3);
}

.toast-action .btn {
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

/* -------------------------------------------------------------------------
   CONFIRMATION TOAST (larger, centered)
   ------------------------------------------------------------------------- */

.toast-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 340px;
  width: calc(100% - var(--space-8));
  text-align: center;
  padding: var(--space-6);
  border-left: none;
  border-radius: var(--radius-3xl);
  animation: toastConfirmIn var(--duration-300) var(--ease-spring);
}

.toast-confirm::before {
  display: none;
}

@keyframes toastConfirmIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.toast-confirm .toast-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-5);
  border-radius: var(--radius-2xl);
}

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

.toast-confirm .toast-title {
  font-size: var(--text-xl);
}

.toast-confirm .toast-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.toast-confirm .toast-actions .btn {
  flex: 1;
}

/* Confirm backdrop */
.toast-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: calc(var(--z-toast) - 1);
  animation: fadeIn var(--duration-200) var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* -------------------------------------------------------------------------
   OFFLINE TOAST (persistent)
   ------------------------------------------------------------------------- */

.toast-offline {
  background: var(--gradient-primary);
  border-left-color: var(--color-primary-800);
  color: white;
}

.toast-offline::before {
  display: none;
}

.toast-offline .toast-icon {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.toast-offline .toast-title {
  color: white;
}

.toast-offline .toast-message {
  color: var(--color-primary-200);
}

.toast-offline .toast-close {
  color: var(--color-primary-200);
}

.toast-offline .toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* -------------------------------------------------------------------------
   SIMPLE SNACKBAR (minimal toast at bottom)
   ------------------------------------------------------------------------- */

.snackbar-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-4) + var(--safe-area-inset-bottom));
  left: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.snackbar {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-slate-900);
  color: white;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xl);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  pointer-events: auto;
  animation: snackbarIn var(--duration-300) var(--ease-spring);
}

.snackbar.is-leaving {
  animation: snackbarOut var(--duration-200) var(--ease-in) forwards;
}

@keyframes snackbarIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes snackbarOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(24px) scale(0.9);
  }
}

.snackbar-action {
  color: var(--color-accent-400);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  padding: var(--space-1) var(--space-2);
  margin: calc(var(--space-1) * -1) calc(var(--space-2) * -1);
  border-radius: var(--radius-md);
  transition: background var(--duration-150) var(--ease-out);
}

.snackbar-action:hover {
  background: rgba(255, 255, 255, 0.1);
}
