/* PWA-specific styles */

/* Manual Install Button */
.manual-install-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(33, 150, 243, 0.4);
  z-index: 9999;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(33, 150, 243, 0.5);
}

.manual-install-btn:active {
  transform: translateY(0);
}

.manual-install-btn.hidden {
  display: none;
}

/* Install Banner */
.pwa-install-banner {
  position: fixed;
  bottom: -100px;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: white;
  padding: 16px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  transition: bottom 0.3s ease;
}

.pwa-install-banner.visible {
  bottom: 0;
}

.pwa-install-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.pwa-install-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.pwa-install-text {
  flex: 1;
}

.pwa-install-text strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.pwa-install-text p {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
}

.pwa-install-button {
  background: white;
  color: #1976d2;
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.pwa-install-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.pwa-install-button:active {
  transform: translateY(0);
}

.pwa-install-dismiss {
  background: transparent;
  border: none;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.8;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.pwa-install-dismiss:hover {
  opacity: 1;
}

/* Network Status Indicator */
.pwa-network-indicator {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 35, 50, 0.95);
  backdrop-filter: blur(10px);
  color: white;
  padding: 12px 24px;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  transition: top 0.3s ease;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.pwa-network-indicator.visible {
  top: 0;
}

.pwa-network-indicator.online {
  background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
}

.pwa-network-indicator.offline {
  background: linear-gradient(135deg, #ffc107 0%, #f57c00 100%);
}

/* Update Notification */
.pwa-update-notification {
  position: fixed;
  top: -100px;
  right: 20px;
  background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
  color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 9998;
  transition: top 0.3s ease;
  max-width: 320px;
}

.pwa-update-notification.visible {
  top: 20px;
}

.pwa-update-content strong {
  display: block;
  font-size: 16px;
  margin-bottom: 8px;
}

.pwa-update-content p {
  font-size: 14px;
  margin: 0 0 16px 0;
  opacity: 0.9;
}

.pwa-update-button,
.pwa-update-dismiss {
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s;
  margin-right: 8px;
}

.pwa-update-button {
  background: white;
  color: #7b1fa2;
}

.pwa-update-button:hover {
  transform: translateY(-2px);
}

.pwa-update-dismiss {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.pwa-update-dismiss:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* PWA Installed State Adjustments */
.pwa-installed .top-nav {
  /* Add extra padding if needed for notch/safe areas */
  padding-top: env(safe-area-inset-top);
}

.pwa-installed .pwa-install-banner {
  display: none;
}

/* Mobile-specific PWA adjustments */
@media (max-width: 768px) {
  .pwa-install-banner {
    padding: 12px;
  }

  .pwa-install-content {
    flex-wrap: wrap;
  }

  .pwa-install-icon {
    font-size: 24px;
  }

  .pwa-install-text strong {
    font-size: 14px;
  }

  .pwa-install-text p {
    font-size: 12px;
  }

  .pwa-install-button {
    padding: 8px 16px;
    font-size: 13px;
  }

  .pwa-update-notification {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

/* iOS specific PWA styles */
@supports (-webkit-touch-callout: none) {
  .pwa-installed {
    /* iOS notch/safe area support */
    padding-top: constant(safe-area-inset-top);
    padding-top: env(safe-area-inset-top);
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: constant(safe-area-inset-left);
    padding-left: env(safe-area-inset-left);
    padding-right: constant(safe-area-inset-right);
    padding-right: env(safe-area-inset-right);
  }
}

/* Loading indicator for offline sync */
.pwa-sync-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(33, 150, 243, 0.9);
  backdrop-filter: blur(10px);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.pwa-sync-indicator.active {
  opacity: 1;
  transform: translateY(0);
}

.pwa-sync-indicator::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Splash screen improvements for installed app */
@media (display-mode: standalone) {
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0a0e1a 0%, #1a2332 100%);
    z-index: -1;
  }
}

/* Add to Home Screen button (optional) */
.add-to-home-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
  color: white;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 999;
  display: none;
}

.add-to-home-button.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-to-home-button:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.5);
}

.add-to-home-button:active {
  transform: translateY(-2px);
}

/* Prevent pull-to-refresh on PWA */
@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: contain;
  }
}
