<div class="toast-container">
  <div class="toast-demo">
    <button class="toast-btn" data-type="success">Toast de Éxito</button>
    <button class="toast-btn" data-type="error">Toast de Error</button>
    <button class="toast-btn" data-type="warning">Toast de Advertencia</button>
    <button class="toast-btn" data-type="info">Toast de Información</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);
}
/* Estilos de toast */
.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);
}
/* Animaciones */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
/* Barra de progreso */
.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);
  }
}
/* Responsivo */
@media (max-width: 768px) {
  .toast {
    right: 15px;
    left: 15px;
    max-width: none;
  }
}
     document.addEventListener('DOMContentLoaded', function() {
  // Obtener elementos del DOM
  const toastButtons = document.querySelectorAll('.toast-btn');
  
  // Mensajes de toast
  const toastMessages = {
    success: {
      icon: '✓',
      message: '¡Operación completada con éxito!'
    },
    error: {
      icon: '✕',
      message: 'Algo salió mal. Por favor, inténtalo de nuevo.'
    },
    warning: {
      icon: '⚠',
      message: 'Este es un mensaje de advertencia.'
    },
    info: {
      icon: 'ℹ',
      message: 'Aquí tienes información útil.'
    }
  };
  
  // Añadir escuchadores de eventos a los botones
  toastButtons.forEach(button => {
    button.addEventListener('click', () => {
      const type = button.getAttribute('data-type');
      showToast(type, toastMessages[type].message, toastMessages[type].icon);
    });
  });
  
  // Función para mostrar toast
  function showToast(type, message, icon) {
    // Crear elemento toast
    const toast = document.createElement('div');
    toast.className = `toast ${type}`;
    
    // Añadir contenido
    toast.innerHTML = `
      <span class="toast-icon">${icon}</span>
      <div class="toast-content">${message}</div>
      <button class="toast-close">×</button>
      <div class="toast-progress"></div>
    `;
    
    // Añadir al documento
    document.body.appendChild(toast);
    
    // Añadir funcionalidad de cierre
    const closeButton = toast.querySelector('.toast-close');
    closeButton.addEventListener('click', () => {
      toast.style.animation = 'fadeOut 0.3s ease';
      setTimeout(() => {
        toast.remove();
      }, 300);
    });
    
    // Eliminar automáticamente después de 5 segundos
    setTimeout(() => {
      if (toast.parentElement) {
        toast.style.animation = 'fadeOut 0.3s ease';
        setTimeout(() => {
          toast.remove();
        }, 300);
      }
    }, 5000);
  }
});