.notification-badge-container {
  background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
  padding: 40px 20px;
  border-radius: 20px;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
}
.notification-badge-demo {
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.03);
}
.demo-header {
  text-align: center;
  margin-bottom: 30px;
}
.demo-header h2 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 2rem;
  font-weight: 700;
}
.demo-header p {
  color: #666;
  font-size: 1.1rem;
  margin: 0;
}
.badges-wrapper {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 30px;
  margin-bottom: 30px;
}
.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}
.icon-wrapper {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}
.icon-wrapper:hover {
  background: #f1f5f9;
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}
.icon {
  font-size: 2rem;
  transition: all 0.3s ease;
}
.icon-wrapper:hover .icon {
  transform: scale(1.1);
}
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
  transition: all 0.3s ease;
  animation: bounceIn 0.6s ease-out;
}
.notification-badge.success {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
  box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3);
}
.notification-badge.warning {
  background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
  box-shadow: 0 3px 10px rgba(243, 156, 18, 0.3);
}
.notification-badge.error {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  box-shadow: 0 3px 10px rgba(231, 76, 60, 0.3);
}
.notification-badge.pulse {
  animation: pulse 2s infinite;
}
.notification-badge.bounce {
  animation: bounce 0.6s ease-out;
}
.badge-label {
  color: #666;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
}
.icon-wrapper:hover .badge-label {
  color: #333;
  transform: translateY(-2px);
}
.controls-wrapper {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
}
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}
.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}
.btn-secondary {
  background: #f1f5f9;
  color: #666;
}
.btn-secondary:hover {
  background: #e2e8f0;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}
/* Animaciones */
@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.5);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
  }
}
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translate(0, 0);
  }
  40% {
    transform: translate(0, -10px);
  }
  60% {
    transform: translate(0, -5px);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}
.badge-item {
  animation: fadeIn 0.6s ease-out;
}
.badge-item:nth-child(1) { animation-delay: 0.1s; }
.badge-item:nth-child(2) { animation-delay: 0.2s; }
.badge-item:nth-child(3) { animation-delay: 0.3s; }
.badge-item:nth-child(4) { animation-delay: 0.4s; }
/* Responsivo */
@media (max-width: 768px) {
  .notification-badge-container {
    padding: 30px 15px;
  }
  
  .notification-badge-demo {
    padding: 25px;
  }
  
  .demo-header h2 {
    font-size: 1.7rem;
  }
  
  .badges-wrapper {
    gap: 20px;
  }
  
  .icon-wrapper {
    width: 70px;
    height: 70px;
  }
  
  .icon {
    font-size: 1.7rem;
  }
  
  .notification-badge {
    width: 25px;
    height: 25px;
    font-size: 0.7rem;
  }
  
  .controls-wrapper {
    flex-direction: column;
    gap: 10px;
  }
  
  .btn {
    width: 100%;
  }
}
@media (max-width: 480px) {
  .badges-wrapper {
    gap: 15px;
  }
  
  .icon-wrapper {
    width: 60px;
    height: 60px;
  }
  
  .icon {
    font-size: 1.5rem;
  }
  
  .badge-label {
    font-size: 0.8rem;
  }
}
     document.addEventListener('DOMContentLoaded', function() {
  // Obtener elementos del DOM
  const notificationBadges = document.querySelectorAll('.notification-badge');
  const addNotificationBtn = document.getElementById('addNotificationBtn');
  const clearNotificationsBtn = document.getElementById('clearNotificationsBtn');
  const iconWrappers = document.querySelectorAll('.icon-wrapper');
  
  // Evento del botón agregar notificación
  addNotificationBtn.addEventListener('click', function() {
    // Agregar notificaciones aleatorias a las insignias
    notificationBadges.forEach(badge => {
      const currentCount = parseInt(badge.textContent);
      const newCount = currentCount + Math.floor(Math.random() * 3) + 1;
      updateBadgeCount(badge, newCount);
      
      // Agregar animación
      badge.classList.add('bounce');
      setTimeout(() => {
        badge.classList.remove('bounce');
      }, 600);
    });
    
    // Agregar animación de pulso a todas las insignias
    notificationBadges.forEach(badge => {
      badge.classList.add('pulse');
      setTimeout(() => {
        badge.classList.remove('pulse');
      }, 2000);
    });
  });
  
  // Evento del botón limpiar notificaciones
  clearNotificationsBtn.addEventListener('click', function() {
    // Limpiar todas las notificaciones
    notificationBadges.forEach(badge => {
      updateBadgeCount(badge, 0);
      
      // Agregar animación de desvanecimiento
      badge.style.animation = 'fadeOut 0.3s ease';
      setTimeout(() => {
        badge.style.animation = '';
      }, 300);
    });
    
    // Mostrar mensaje de confirmación
    showMessage('¡Todas las notificaciones han sido limpiadas!', 'success');
  });
  
  // Eventos de clic en envoltorios de iconos
  iconWrappers.forEach((wrapper, index) => {
    wrapper.addEventListener('click', function() {
      const badge = notificationBadges[index];
      const currentCount = parseInt(badge.textContent);
      
      if (currentCount > 0) {
        // Decrementar conteo de notificaciones
        const newCount = currentCount - 1;
        updateBadgeCount(badge, newCount);
        
        // Agregar animación de rebote
        badge.classList.add('bounce');
        setTimeout(() => {
          badge.classList.remove('bounce');
        }, 600);
        
        // Mostrar mensaje de notificación
        const iconName = wrapper.querySelector('.icon').textContent;
        showMessage(`Notificación descartada de ${iconName}`, 'info');
      } else {
        // Mostrar mensaje vacío
        showMessage('No hay notificaciones para descartar', 'warning');
      }
    });
  });
  
  // Actualizar conteo de insignia
  function updateBadgeCount(badge, count) {
    if (count > 0) {
      badge.textContent = count > 99 ? '99+' : count;
      badge.style.display = 'flex';
    } else {
      badge.textContent = '0';
      badge.style.display = 'none';
    }
  }
  
  // Mostrar mensaje
  function showMessage(text, type) {
    // Crear elemento de mensaje
    const message = document.createElement('div');
    message.className = `message ${type}`;
    message.textContent = text;
    message.style.cssText = `
      position: fixed;
      bottom: 20px;
      right: 20px;
      background: ${getMessageColor(type)};
      color: white;
      padding: 15px 25px;
      border-radius: 10px;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
      z-index: 1000;
      transform: translateY(20px);
      opacity: 0;
      transition: all 0.3s ease;
      font-weight: 500;
    `;
    
    document.body.appendChild(message);
    
    // Animar entrada
    setTimeout(() => {
      message.style.transform = 'translateY(0)';
      message.style.opacity = '1';
    }, 100);
    
    // Eliminar después del retraso
    setTimeout(() => {
      message.style.transform = 'translateY(20px)';
      message.style.opacity = '0';
      setTimeout(() => {
        document.body.removeChild(message);
      }, 300);
    }, 3000);
  }
  
  // Obtener color de mensaje basado en tipo
  function getMessageColor(type) {
    switch(type) {
      case 'success':
        return 'linear-gradient(135deg, #27ae60 0%, #2ecc71 100%)';
      case 'warning':
        return 'linear-gradient(135deg, #f39c12 0%, #e67e22 100%)';
      case 'error':
        return 'linear-gradient(135deg, #e74c3c 0%, #c0392b 100%)';
      default:
        return 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)';
    }
  }
  
  // Inicializar insignias con animación de pulso
  setTimeout(() => {
    notificationBadges.forEach(badge => {
      badge.classList.add('pulse');
      setTimeout(() => {
        badge.classList.remove('pulse');
      }, 2000);
    });
  }, 1000);
});