<div class="toast-container">
  <div class="toast-demo">
    <button class="toast-btn" data-type="success">Success Toast</button>
    <button class="toast-btn" data-type="error">Error Toast</button>
    <button class="toast-btn" data-type="warning">Warning Toast</button>
    <button class="toast-btn" data-type="info">Info Toast</button>
  </div>
</div>
     .toast-container {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 40px 20px;
  border-radius: 15px;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast-demo {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
}
.toast-btn {
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}
.toast-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
/* Toast styles */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 24px;
  border-radius: 12px;
  color: white;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1000;
  max-width: 350px;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 4.7s;
  transform: translateX(0);
  opacity: 1;
}
.toast.success {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}
.toast.error {
  background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
}
.toast.warning {
  background: linear-gradient(135deg, #d35400 0%, #f39c12 100%);
  color: #333;
}
.toast.info {
  background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
}
.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.toast-content {
  flex: 1;
}
.toast-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}
.toast-close:hover {
  background: rgba(255, 255, 255, 0.2);
}
/* Animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
/* Progress bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  width: 100%;
  transform-origin: left;
  animation: progress 5s linear;
}
@keyframes progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}
/* Responsive */
@media (max-width: 768px) {
  .toast {
    right: 15px;
    left: 15px;
    max-width: none;
  }
}
     document.addEventListener('DOMContentLoaded', function() {
  // Get DOM elements
  const toastButtons = document.querySelectorAll('.toast-btn');
  
  // Toast messages
  const toastMessages = {
    success: {
      icon: '✓',
      message: 'Operation completed successfully!'
    },
    error: {
      icon: '✕',
      message: 'Something went wrong. Please try again.'
    },
    warning: {
      icon: '⚠',
      message: 'This is a warning message.'
    },
    info: {
      icon: 'ℹ',
      message: 'Here is some useful information.'
    }
  };
  
  // Add event listeners to buttons
  toastButtons.forEach(button => {
    button.addEventListener('click', () => {
      const type = button.getAttribute('data-type');
      showToast(type, toastMessages[type].message, toastMessages[type].icon);
    });
  });
  
  // Show toast function
  function showToast(type, message, icon) {
    // Create toast element
    const toast = document.createElement('div');
    toast.className = `toast ${type}`;
    
    // Add content
    toast.innerHTML = `
      <span class="toast-icon">${icon}</span>
      <div class="toast-content">${message}</div>
      <button class="toast-close">×</button>
      <div class="toast-progress"></div>
    `;
    
    // Add to document
    document.body.appendChild(toast);
    
    // Add close functionality
    const closeButton = toast.querySelector('.toast-close');
    closeButton.addEventListener('click', () => {
      toast.style.animation = 'fadeOut 0.3s ease';
      setTimeout(() => {
        toast.remove();
      }, 300);
    });
    
    // Auto remove after 5 seconds
    setTimeout(() => {
      if (toast.parentElement) {
        toast.style.animation = 'fadeOut 0.3s ease';
        setTimeout(() => {
          toast.remove();
        }, 300);
      }
    }, 5000);
  }
});