/* Estilos PWA - Notificaciones y Banners */

/* Banner de instalación PWA */
.pwa-install-banner {
  position: fixed;
  bottom: -200px;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  transition: bottom 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.pwa-install-banner.show {
  bottom: 0;
}

.pwa-banner-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.pwa-banner-icon {
  font-size: 40px;
  flex-shrink: 0;
}

.pwa-banner-text {
  flex: 1;
  min-width: 200px;
}

.pwa-banner-text strong {
  display: block;
  font-size: 18px;
  margin-bottom: 5px;
}

.pwa-banner-text p {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
}

.pwa-banner-btn,
.pwa-banner-close {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  padding: 10px 25px;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.pwa-banner-btn:hover {
  background: white;
  color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

.pwa-banner-close {
  padding: 10px 15px;
  min-width: auto;
}

.pwa-banner-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Notificación de actualización */
.pwa-update-notification {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 15px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  padding: 20px;
  z-index: 10000;
  min-width: 350px;
  max-width: 90%;
  transition: top 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.pwa-update-notification.show {
  top: 20px;
}

.pwa-notification-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.pwa-notification-icon {
  font-size: 35px;
  flex-shrink: 0;
}

.pwa-notification-text {
  flex: 1;
}

.pwa-notification-text strong {
  display: block;
  color: #333;
  font-size: 16px;
  margin-bottom: 5px;
}

.pwa-notification-text p {
  color: #666;
  font-size: 14px;
  margin: 0;
}

.pwa-notification-btn,
.pwa-notification-close {
  background: #2563eb;
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.pwa-notification-btn:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.pwa-notification-close {
  background: transparent;
  color: #999;
  padding: 8px 12px;
  font-size: 20px;
  line-height: 1;
}

.pwa-notification-close:hover {
  background: #f3f4f6;
  color: #333;
}

/* Estado de conexión */
.pwa-connection-status {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  color: #333;
  padding: 15px 30px;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  z-index: 10001;
  font-weight: bold;
  font-size: 14px;
  transition: top 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  gap: 10px;
}

.pwa-connection-status.show {
  top: 20px;
}

.pwa-connection-status::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: block;
}

.pwa-status-success {
  background: #10b981;
  color: white;
}

.pwa-status-success::before {
  background: white;
}

.pwa-status-warning {
  background: #f59e0b;
  color: white;
}

.pwa-status-warning::before {
  background: white;
}

.pwa-status-error {
  background: #ef4444;
  color: white;
}

.pwa-status-error::before {
  background: white;
}

/* Botón de instalación personalizado */
#pwa-install-button {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  z-index: 9998;
  transition: all 0.3s ease;
}

#pwa-install-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

#pwa-install-button:active {
  transform: translateY(-1px);
}

/* Ajustes para modo standalone (PWA instalada) */
.pwa-standalone {
  /* Agregar padding extra si es necesario cuando está en modo standalone */
}

/* Ajustes para iOS */
@supports (-webkit-touch-callout: none) {
  .pwa-install-banner {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  body.pwa-standalone {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Animaciones */
@keyframes slideInFromTop {
  from {
    transform: translate(-50%, -150%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@keyframes slideInFromBottom {
  from {
    transform: translateY(150%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Spinner de carga para sincronización */
.pwa-sync-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Badge de contador offline */
.pwa-offline-badge {
  position: relative;
}

.pwa-offline-badge::after {
  content: attr(data-offline-count);
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
}

/* Indicador de conexión en header */
.pwa-connection-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  background: #10b981;
  animation: pulse-online 2s infinite;
}

.pwa-connection-indicator.offline {
  background: #ef4444;
  animation: pulse-offline 2s infinite;
}

@keyframes pulse-online {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
  }
}

@keyframes pulse-offline {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
  }
}

/* Responsive */
@media (max-width: 640px) {
  .pwa-banner-content {
    flex-direction: column;
    text-align: center;
  }

  .pwa-banner-btn,
  .pwa-banner-close {
    width: 100%;
  }

  .pwa-update-notification {
    min-width: auto;
    width: 90%;
  }

  .pwa-notification-content {
    flex-direction: column;
    text-align: center;
  }

  #pwa-install-button {
    bottom: 10px;
    right: 10px;
    left: 10px;
    width: calc(100% - 20px);
  }
}
