/**
 * AUTOAID Toast Notification System - Complete Redesign
 * Modern, Minimalist, Accessible & Fully Responsive
 * Features: Smooth animations, Multiple types, Auto-dismiss, Progress tracking
 */

:root {
  /* Color Palette */
  --toast-bg: #ffffff;
  --toast-text-primary: #1a1a2e;
  --toast-text-secondary: #666;
  
  /* Toast Type Colors */
  --success-color: #22c55e;
  --success-bg: #f0fdf4;
  --success-border: #86efac;
  
  --error-color: #ef4444;
  --error-bg: #fef2f2;
  --error-border: #fca5a5;
  
  --warning-color: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  
  --info-color: #3b82f6;
  --info-bg: #eff6ff;
  --info-border: #93c5fd;
  
  /* Effects & Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
  --radius: 10px;
  --transition: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   TOAST CONTAINER - Fixed Positioning
   ========================================== */

#toastContainer {
  position: fixed;
  top: 28px;
  right: 28px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 85vh;
  max-width: 500px;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

#toastContainer::-webkit-scrollbar {
  width: 6px;
}

#toastContainer::-webkit-scrollbar-track {
  background: transparent;
}

#toastContainer::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

/* ==========================================
   INDIVIDUAL TOAST - Base Structure
   ========================================== */

.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: var(--toast-bg);
  border-left: 5px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 340px;
  max-width: 100%;
  pointer-events: auto;
  cursor: default;
  overflow: hidden;
  position: relative;
  
  /* Typography */
  font-size: 14px;
  line-height: 1.5;
  color: var(--toast-text-primary);
  
  /* Animations */
  animation: toastEnter 0.6s var(--transition) backwards;
  animation-fill-mode: both;
  
  /* Accessibility */
  will-change: transform, opacity;
}

/* ==========================================
   TOAST ANIMATIONS - Entrance & Exit
   ========================================== */

@keyframes toastEnter {
  from {
    opacity: 0;
    transform: translateX(400px) scale(0.8) rotateY(-10deg);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1) rotateY(0deg);
    filter: blur(0);
  }
}

@keyframes toastExit {
  from {
    opacity: 1;
    transform: translateX(0) scale(1) rotateY(0deg);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateX(400px) scale(0.8) rotateY(-10deg);
    filter: blur(10px);
  }
}

.toast.removing {
  animation: toastExit 0.5s var(--transition) forwards;
}

/* ==========================================
   TOAST ICON - Animated Entry
   ========================================== */

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 600;
  border-radius: 50%;
  grid-column: 1;
  grid-row: 1;
  
  /* Icon animation */
  animation: iconPulse 0.6s var(--transition) 0.2s backwards;
}

@keyframes iconPulse {
  0% {
    transform: scale(0) rotate(-45deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* ==========================================
   TOAST CONTENT - Message & Title
   ========================================== */

.toast-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  grid-column: 2;
  grid-row: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 14px;
  margin: 0;
  letter-spacing: 0.3px;
}

.toast-message {
  font-weight: 500;
  font-size: 13px;
  color: var(--toast-text-secondary);
  margin: 0;
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.5;
}

/* ==========================================
   TOAST CLOSE BUTTON - Interactive
   ========================================== */

.toast-close {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 3;
  grid-row: 1;
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #999;
  font-size: 20px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: all 0.3s var(--transition);
  
  /* Better touch target */
  min-width: 40px;
  min-height: 40px;
}

.toast-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #333;
  transform: rotate(90deg) scale(1.1);
}

.toast-close:active {
  transform: rotate(90deg) scale(0.95);
}

.toast-close:focus-visible {
  outline: 2px solid var(--info-color);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================
   PROGRESS BAR - Visual Timer
   ========================================== */

.toast-progress {
  grid-column: 1 / -1;
  grid-row: 2;
  height: 3px;
  width: 100%;
  background: currentColor;
  border-radius: 2px;
  opacity: 0.4;
  margin-top: 4px;
  transform-origin: left;
  animation: progressCountdown linear forwards paused;
}

.toast-progress.active {
  animation-play-state: running;
}

@keyframes progressCountdown {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

/* ==========================================
   SUCCESS TOAST - Green Theme
   ========================================== */

.toast.success {
  border-left-color: var(--success-color);
  background: linear-gradient(135deg, var(--success-bg) 0%, #ffffff 100%);
}

.toast.success .toast-icon {
  background: var(--success-color);
  color: white;
}

.toast.success .toast-title {
  color: var(--success-color);
}

.toast.success .toast-progress {
  background: var(--success-color);
}

/* ==========================================
   ERROR TOAST - Red Theme
   ========================================== */

.toast.error {
  border-left-color: var(--error-color);
  background: linear-gradient(135deg, var(--error-bg) 0%, #ffffff 100%);
}

.toast.error .toast-icon {
  background: var(--error-color);
  color: white;
}

.toast.error .toast-title {
  color: var(--error-color);
}

.toast.error .toast-progress {
  background: var(--error-color);
}

/* ==========================================
   WARNING TOAST - Orange Theme
   ========================================== */

.toast.warning {
  border-left-color: var(--warning-color);
  background: linear-gradient(135deg, var(--warning-bg) 0%, #ffffff 100%);
}

.toast.warning .toast-icon {
  background: var(--warning-color);
  color: white;
}

.toast.warning .toast-title {
  color: var(--warning-color);
}

.toast.warning .toast-progress {
  background: var(--warning-color);
}

/* ==========================================
   INFO TOAST - Blue Theme
   ========================================== */

.toast.info {
  border-left-color: var(--info-color);
  background: linear-gradient(135deg, var(--info-bg) 0%, #ffffff 100%);
}

.toast.info .toast-icon {
  background: var(--info-color);
  color: white;
}

.toast.info .toast-title {
  color: var(--info-color);
}

.toast.info .toast-progress {
  background: var(--info-color);
}

/* ==========================================
   RESPONSIVE DESIGN - Tablets & Mobile
   ========================================== */

@media (max-width: 768px) {
  #toastContainer {
    top: 20px;
    right: 16px;
    left: 16px;
    max-width: none;
    gap: 10px;
  }

  .toast {
    min-width: auto;
    padding: 14px 16px;
    gap: 12px;
    font-size: 13px;
  }

  .toast-icon {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  .toast-title {
    font-size: 13px;
  }

  .toast-message {
    font-size: 12px;
  }

  .toast-close {
    width: 24px;
    height: 24px;
    min-width: 36px;
    min-height: 36px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  #toastContainer {
    top: 16px;
    right: 12px;
    left: 12px;
    gap: 8px;
  }

  .toast {
    padding: 12px 14px;
    min-width: auto;
    gap: 10px;
    font-size: 12px;
  }

  .toast-icon {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .toast-title {
    font-size: 12px;
  }

  .toast-message {
    font-size: 11px;
  }

  .toast-close {
    width: 22px;
    height: 22px;
    min-width: 32px;
    min-height: 32px;
    font-size: 16px;
  }
}

/* ==========================================
   DARK MODE SUPPORT
   ========================================== */

@media (prefers-color-scheme: dark) {
  :root {
    --toast-bg: #2d3748;
    --toast-text-primary: #f3f4f6;
    --toast-text-secondary: #cbd5e1;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  }

  .toast {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  }

  .toast.success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, #2d3748 100%);
  }

  .toast.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, #2d3748 100%);
  }

  .toast.warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, #2d3748 100%);
  }

  .toast.info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, #2d3748 100%);
  }

  .toast-close {
    color: #9ca3af;
  }

  .toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e5e7eb;
  }
}

/* ==========================================
   ACCESSIBILITY - High Contrast & Focus
   ========================================== */

@media (prefers-contrast: more) {
  .toast {
    border-width: 2px;
    box-shadow: 0 0 0 1px #000;
  }

  .toast-title {
    font-weight: 900;
  }

  .toast-icon {
    border: 2px solid currentColor;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast-icon,
  .toast-close,
  .toast-progress {
    animation: none;
    transition: none;
  }

  .toast.removing {
    opacity: 0;
  }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
  #toastContainer,
  .toast {
    display: none !important;
  }
}

