/**
 * CSS para Progressive Web App
 * Inclui: indicadores, prompts de install, notificações
 */

/* ============================================
   INDICADORES DE ONLINE/OFFLINE
   ============================================ */

#pwa-online-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9998;
  animation: slideInUp 0.3s ease-out;
}

#pwa-online-indicator.pwa-online {
  background: #10b981;
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

#pwa-online-indicator.pwa-offline {
  background: #ef4444;
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

#pwa-online-indicator.pwa-hide {
  animation: slideOutDown 0.3s ease-out forwards;
}

/* ============================================
   INSTALL PROMPT / BANNER
   ============================================ */

#pwa-install-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
}

.pwa-install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8c 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  animation: slideDown 0.3s ease-out;
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.pwa-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
}

.pwa-install-content h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.pwa-install-content p {
  margin: 2px 0 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.pwa-install-btn {
  background: white;
  color: #1e3a5f;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  margin: 0 8px;
}

.pwa-install-btn:hover {
  background: #f0f0f0;
  transform: scale(1.05);
}

.pwa-install-btn:active {
  transform: scale(0.98);
}

.pwa-dismiss-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.pwa-dismiss-btn:hover {
  opacity: 0.7;
}

/* ============================================
   UPDATE PROMPT
   ============================================ */

.pwa-update-prompt {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9998;
  animation: slideInUp 0.3s ease-out;
  max-width: 300px;
}

.pwa-update-content {
  padding: 16px;
}

.pwa-update-content p {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #1e3a5f;
}

.pwa-update-content button {
  display: block;
  width: 100%;
  padding: 8px;
  margin: 4px 0;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pwa-update-reload {
  background: #10b981;
  color: white;
  font-weight: 600;
}

.pwa-update-reload:hover {
  background: #059669;
}

.pwa-update-dismiss {
  background: #f3f4f6;
  color: #6b7280;
  font-weight: 500;
}

.pwa-update-dismiss:hover {
  background: #e5e7eb;
}

/* ============================================
   ANIMAÇÕES
   ============================================ */

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(20px);
    opacity: 0;
  }
}

/* ============================================
   ESTADOS INSTALADOS
   ============================================ */

body.pwa-installed {
  /* Estiços adicionais para app instalado */
  padding-top: 0; /* Remove padding se banner foi removido */
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
  .pwa-install-banner {
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .pwa-install-content {
    flex: 1 1 100%;
  }
  
  .pwa-install-btn,
  .pwa-dismiss-btn {
    flex: 1;
  }
  
  #pwa-online-indicator {
    font-size: 12px;
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
}

/* ============================================
   DARK MODE
   ============================================ */

@media (prefers-color-scheme: dark) {
  .pwa-update-prompt {
    background: #1f2937;
    color: white;
  }
  
  .pwa-update-content p {
    color: #f3f4f6;
  }
  
  .pwa-update-dismiss {
    background: #374151;
    color: #d1d5db;
  }
  
  .pwa-update-dismiss:hover {
    background: #4b5563;
  }
}
