/* PWA-specific styles */
/* Install button, offline indicator, iOS instructions, update notifications */

/* Install Button */
.pwa-install-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: none; /* Hidden by default, shown by JS */
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  z-index: 1000;
  animation: pulse-glow 2s ease-in-out infinite;
}

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

.pwa-install-button:active {
  transform: translateY(0);
}

.pwa-install-button svg {
  flex-shrink: 0;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  }
  50% {
    box-shadow: 0 4px 30px rgba(102, 126, 234, 0.7);
  }
}

/* Offline Indicator */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: #ff6b6b;
  color: white;
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.offline-indicator svg {
  flex-shrink: 0;
}

/* iOS Install Banner */
.ios-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 20px;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
  animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.ios-install-content {
  max-width: 600px;
  margin: 0 auto;
}

.ios-install-content p {
  margin: 0 0 10px 0;
  font-weight: 600;
  font-size: 16px;
}

.ios-install-content ol {
  margin: 10px 0;
  padding-left: 20px;
  font-size: 14px;
}

.ios-install-content li {
  margin: 5px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ios-install-content li svg {
  flex-shrink: 0;
}

.ios-install-close {
  margin-top: 15px;
  padding: 8px 20px;
  background: white;
  color: #667eea;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.ios-install-close:hover {
  opacity: 0.9;
}

/* PWA Update Notification */
.pwa-update-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  max-width: 400px;
  animation: slide-down 0.3s ease-out;
}

@keyframes slide-down {
  from {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.pwa-update-content p {
  margin: 0 0 15px 0;
  color: #1a1a24;
  font-weight: 600;
  font-size: 14px;
}

.pwa-update-content button {
  margin-right: 10px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.pwa-update-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.pwa-update-dismiss {
  background: #f5f5f5;
  color: #666;
}

.pwa-update-content button:hover {
  opacity: 0.9;
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
  .pwa-install-button {
    bottom: 80px; /* Account for mobile bottom navigation */
    right: 15px;
    padding: 10px 16px;
    font-size: 13px;
  }

  .ios-install-banner {
    padding: 15px;
  }

  .ios-install-content p {
    font-size: 14px;
  }

  .ios-install-content ol {
    font-size: 13px;
  }

  .pwa-update-notification {
    top: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
  }
}

/* Loading spinner for PWA */
.pwa-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Mobile navigation bar (sticky bottom) */
.mobile-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e0e0e0;
  padding: 10px 0;
  display: none;
  justify-content: space-around;
  z-index: 999;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .mobile-nav-bar {
    display: flex;
  }

  /* Add padding to body to account for mobile nav */
  body.mobile {
    padding-bottom: 70px;
  }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #666;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}

.mobile-nav-item.active {
  color: #667eea;
  background: rgba(102, 126, 234, 0.1);
}

.mobile-nav-item svg {
  width: 24px;
  height: 24px;
}

/* Touch-friendly buttons */
@media (max-width: 768px) {
  button, .button, a.button {
    min-height: 44px; /* iOS recommendation for touch targets */
    min-width: 44px;
  }
}

/* Pull to refresh indicator */
.pull-to-refresh {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #667eea;
  font-size: 14px;
  font-weight: 600;
  transition: top 0.3s;
}

.pull-to-refresh.visible {
  top: 10px;
}

/* Safe area insets for iPhone notch */
@supports (padding: max(0px)) {
  .ios-install-banner {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .mobile-nav-bar {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .pwa-install-button {
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(20px, env(safe-area-inset-right));
  }
}

/* Android-specific back button */
.android-back-button {
  position: fixed;
  top: 10px;
  left: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: none;
  z-index: 1000;
}

.android-back-button.visible {
  display: block;
}

.android-back-button svg {
  width: 24px;
  height: 24px;
}

/* Smooth transitions for PWA mode */
@media (display-mode: standalone) {
  /* Add extra padding for standalone mode */
  body {
    padding-top: env(safe-area-inset-top);
  }

  /* Hide browser-specific UI elements */
  .browser-only {
    display: none !important;
  }
}
