/**
 * Estilos PWA para Soluções Imper
 * Banner de instalação, botões flutuantes e modais
 */

/* ===== BANNER DE INSTALAÇÃO ===== */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  padding: 16px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pwa-install-banner.show {
  transform: translateY(0);
}

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

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

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

.pwa-banner-text h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

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

.pwa-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.pwa-banner-close {
  position: absolute;
  top: -8px;
  right: -8px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

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

/* ===== BOTÕES PWA ===== */
.pwa-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}

.pwa-btn-primary {
  background: white;
  color: #007bff;
}

.pwa-btn-primary:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
}

.pwa-btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.pwa-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== BOTÃO FLUTUANTE ===== */
.pwa-floating-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 123, 255, 0.4);
  z-index: 9999;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-floating-button:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 25px rgba(0, 123, 255, 0.5);
}

.pwa-floating-button:active {
  transform: translateY(0) scale(0.95);
}

/* ===== MODAL DE ATUALIZAÇÃO ===== */
.pwa-update-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.pwa-update-modal.show {
  opacity: 1;
  visibility: visible;
}

.pwa-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.pwa-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.pwa-update-modal.show .pwa-modal-content {
  transform: scale(1);
}

.pwa-modal-header {
  padding: 20px 20px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pwa-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.pwa-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.pwa-modal-close:hover {
  background: #f8f9fa;
}

.pwa-modal-body {
  padding: 20px;
}

.pwa-modal-body p {
  margin: 0;
  color: #666;
  line-height: 1.5;
}

.pwa-modal-footer {
  padding: 0 20px 20px 20px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ===== INDICADOR OFFLINE ===== */
.pwa-offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #dc3545;
  color: white;
  padding: 8px 16px;
  text-align: center;
  z-index: 10002;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  font-size: 14px;
  font-weight: 500;
}

.pwa-offline-indicator.show {
  transform: translateY(0);
}

.pwa-offline-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pwa-offline-icon {
  font-size: 16px;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
  .pwa-banner-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .pwa-banner-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .pwa-banner-text h3 {
    font-size: 16px;
  }
  
  .pwa-banner-text p {
    font-size: 13px;
  }
  
  .pwa-floating-button {
    bottom: 80px; /* Evita conflito com banner */
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  .pwa-modal-content {
    margin: 20px;
    width: calc(100% - 40px);
  }
  
  .pwa-modal-footer {
    flex-direction: column;
  }
  
  .pwa-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .pwa-install-banner {
    padding: 12px;
  }
  
  .pwa-banner-icon {
    font-size: 28px;
  }
  
  .pwa-banner-text h3 {
    font-size: 15px;
  }
  
  .pwa-banner-text p {
    font-size: 12px;
  }
  
  .pwa-btn {
    padding: 6px 12px;
    font-size: 13px;
    min-height: 32px;
  }
}

/* ===== ANIMAÇÕES ===== */
@keyframes pwa-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
  }
}

.pwa-floating-button.pulse {
  animation: pwa-pulse 2s infinite;
}

/* ===== ESTADOS DE CARREGAMENTO ===== */
.pwa-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.pwa-btn.loading {
  position: relative;
  color: transparent;
}

.pwa-btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: pwa-spin 1s linear infinite;
}

@keyframes pwa-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== ACESSIBILIDADE ===== */
@media (prefers-reduced-motion: reduce) {
  .pwa-install-banner,
  .pwa-update-modal,
  .pwa-offline-indicator,
  .pwa-floating-button,
  .pwa-btn {
    transition: none;
  }
  
  .pwa-floating-button.pulse {
    animation: none;
  }
  
  .pwa-btn.loading::after {
    animation: none;
  }
}

/* ===== MODO ESCURO ===== */
@media (prefers-color-scheme: dark) {
  .pwa-modal-content {
    background: #2d3748;
    color: #e2e8f0;
  }
  
  .pwa-modal-header h3 {
    color: #e2e8f0;
  }
  
  .pwa-modal-close {
    color: #a0aec0;
  }
  
  .pwa-modal-close:hover {
    background: #4a5568;
  }
  
  .pwa-modal-body p {
    color: #a0aec0;
  }
}

/* ===== IMPRESSÃO ===== */
@media print {
  .pwa-install-banner,
  .pwa-floating-button,
  .pwa-update-modal,
  .pwa-offline-indicator {
    display: none !important;
  }
}
