/**
 * Centralized Toast Notification Styles
 * Replaces all scattered toast CSS across the project
 * Clean, modern design with consistent animations
 */

/* Toast Container */
.toast-container {
  position: fixed !important;
  top: 20px !important;
  right: 20px !important;
  z-index: 999999 !important; /* Much higher than any overlay */
  pointer-events: none !important;
  max-width: 450px !important;
  width: auto !important;
  height: auto !important;
  /* Ensure it's not affected by any parent transforms */
  transform: none !important;
  /* Ensure it appears above everything */
  isolation: isolate !important;
}

/* Base Toast Styles */
.toast {
  background: rgba(59, 130, 246, 0.95);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.15),
    0 4px 20px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: none;
  align-items: center;
  gap: 0.75rem;
  max-width: 400px;
  min-width: 300px;
  transform: translateX(420px) scale(0.9);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.175);
  pointer-events: auto;
  position: relative;
  opacity: 0;
  visibility: hidden;
  margin-bottom: 1rem;
  z-index: 999999 !important; /* Ensure toast itself has high z-index */
}

.toast.show {
  display: flex;
  transform: translateX(0) scale(1);
  opacity: 1;
  visibility: visible;
}

/* Toast Icon */
.toast-icon {
  flex-shrink: 0;
  font-size: 1.25rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast Content */
.toast-content {
  flex: 1;
}

.toast-message {
  font-weight: 500;
  font-size: 0.9rem;
  line-height: 1.4;
  word-wrap: break-word;
}

/* Toast Close Button */
.toast-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.toast-close i {
  font-size: 0.875rem;
}

/* Toast Type Variants */

/* Success Toast */
.toast.success {
  background: rgba(34, 197, 94, 0.95);
  border-color: rgba(34, 197, 94, 0.3);
}

.toast.success .toast-close {
  color: rgba(255, 255, 255, 0.9);
}

/* Error Toast */
.toast.error {
  background: rgba(239, 68, 68, 0.95) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  box-shadow: 
    0 10px 40px rgba(239, 68, 68, 0.3),
    0 4px 20px rgba(239, 68, 68, 0.2) !important;
}

.toast.error .toast-close {
  color: rgba(255, 255, 255, 0.9);
}

/* Warning Toast */
.toast.warning {
  background: rgba(245, 158, 11, 0.95);
  border-color: rgba(245, 158, 11, 0.3);
}

.toast.warning .toast-close {
  color: rgba(255, 255, 255, 0.9);
}

/* Info Toast (default) */
.toast.info {
  background: rgba(59, 130, 246, 0.95);
  border-color: rgba(59, 130, 246, 0.3);
}

/* Production Notice Toast - Special styling for important announcements */
.toast.production-notice {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-left: 4px solid #6366f1;
  box-shadow: 
    0 12px 30px rgba(0, 0, 0, 0.12),
    0 4px 16px rgba(0, 0, 0, 0.08);
  max-width: 450px;
  min-width: 350px;
  padding: 1.25rem 1.5rem;
  backdrop-filter: blur(20px);
}

.toast.production-notice .toast-icon {
  display: none !important;
}

.toast.production-notice .toast-message {
  color: #374151;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
}

.toast.production-notice .toast-close {
  color: #94a3b8;
}

.toast.production-notice .toast-close:hover {
  color: #64748b;
  background: rgba(148, 163, 184, 0.1);
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
  .toast-container {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
  }
  
  .toast {
    min-width: auto;
    width: 100%;
    max-width: none;
    margin-bottom: 0.75rem;
  }

  .toast.production-notice {
    min-width: auto;
    max-width: none;
    padding: 1rem 1.25rem;
  }

  .toast-message {
    font-size: 0.85rem;
  }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
  .toast-container {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
  }

  .toast {
    padding: 0.875rem 1rem;
    border-radius: 8px;
  }

  .toast.production-notice {
    padding: 1rem;
  }

  .toast-message {
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .toast-icon {
    font-size: 1.1rem;
  }
}

/* Animation Enhancements */
@keyframes toastSlideIn {
  from {
    transform: translateX(420px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateX(420px) scale(0.9);
    opacity: 0;
  }
}

/* Enhanced animations for better UX */
.toast.show {
  animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.175) forwards;
}

.toast:not(.show) {
  animation: toastSlideOut 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards;
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: opacity 0.2s ease;
  }
  
  .toast.show {
    animation: none;
    transform: translateX(0) scale(1);
  }
  
  .toast:not(.show) {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .toast {
    border: 2px solid;
    backdrop-filter: none;
  }
  
  .toast.success {
    background: #22c55e;
    border-color: #16a34a;
  }
  
  .toast.error {
    background: #ef4444;
    border-color: #dc2626;
  }
  
  .toast.warning {
    background: #f59e0b;
    border-color: #d97706;
  }
  
  .toast.info {
    background: #3b82f6;
    border-color: #2563eb;
  }
}

/* Focus management for accessibility */
.toast-close:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.toast.production-notice .toast-close:focus {
  outline: 2px solid #6366f1;
}
