/**
 * Progressive Web App Styles
 * 
 * Styles for PWA-specific UI elements:
 * - Install prompts
 * - Update notifications
 * - Online/offline indicators
 * - Standalone display mode adjustments
 */

/* Install Prompt Container */
#pwa-install-prompt {
  display: none;
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  max-width: 400px;
  background: linear-gradient(135deg, #0a2854 0%, #0066cc 100%);
  color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-prompt-content {
  padding: 1.25rem;
}

.pwa-prompt-content h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.pwa-prompt-content p {
  margin: 0.5rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
  opacity: 0.95;
}

.pwa-prompt-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

.pwa-button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pwa-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pwa-button:active {
  transform: translateY(0);
}

.pwa-button-primary {
  background: #fff;
  color: #0a2854;
}

.pwa-button-primary:hover {
  background: #f0f0f0;
}

.pwa-button-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.pwa-button-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Online/Offline Indicator */
#pwa-online-indicator {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 20px;
  background: #f0f0f0;
  color: #666;
  transition: all 0.2s ease;
}

#pwa-online-indicator.online {
  background: #d4edda;
  color: #28a745;
}

#pwa-online-indicator.offline {
  background: #f8d7da;
  color: #dc3545;
}

/* Offline Banner */
.pwa-offline-banner {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Update Banner */
.pwa-update-banner {
  animation: slideUp 0.3s ease-out;
}

.pwa-update-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pwa-update-button {
  flex-shrink: 0;
}

/* Success Message */
.pwa-success-message {
  animation: popIn 0.3s ease-out;
}

@keyframes popIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.pwa-success-message p {
  margin: 0.25rem 0;
  font-size: 0.95rem;
}

.pwa-success-message p:first-child {
  font-weight: 600;
}

/* Standalone Mode Adjustments */
@media (display-mode: standalone) {
  /* Hide address bar related spacing */
  body {
    padding-bottom: 0.5rem;
  }

  /* Adjust padding for safe area insets (iOS notch support) */
  @supports (padding: max(0px)) {
    body {
      padding-left: max(1rem, env(safe-area-inset-left));
      padding-right: max(1rem, env(safe-area-inset-right));
      padding-top: max(0.5rem, env(safe-area-inset-top));
    }
  }
}

/* iPhone X and later support (notch/safe area) */
@supports (padding: max(0px)) {
  #pwa-install-prompt,
  .pwa-update-banner,
  .pwa-offline-banner {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

/* Mobile viewport optimizations */
@media (max-width: 480px) {
  #pwa-install-prompt {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .pwa-prompt-buttons {
    flex-direction: column;
  }

  .pwa-button {
    width: 100%;
  }

  .pwa-update-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .pwa-success-message {
    left: 0.75rem !important;
    right: 0.75rem !important;
  }
}

/* Tablet and larger */
@media (min-width: 768px) {
  #pwa-install-prompt {
    max-width: 500px;
    right: auto;
    left: 2rem;
    bottom: 2rem;
  }
}

/* Print media - hide PWA UI */
@media print {
  #pwa-install-prompt,
  .pwa-update-banner,
  .pwa-offline-banner,
  .pwa-success-message,
  #pwa-online-indicator {
    display: none !important;
  }
}

/* Accessibility */
.pwa-button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.pwa-button-secondary:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  #pwa-install-prompt {
    background: linear-gradient(135deg, #0a2854 0%, #003d82 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  }

  .pwa-button-secondary {
    border-color: rgba(255, 255, 255, 0.2);
  }

  #pwa-online-indicator {
    background: #1e1e1e;
    color: #ccc;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  #pwa-install-prompt,
  .pwa-update-banner,
  .pwa-offline-banner,
  .pwa-success-message,
  .pwa-button {
    animation: none !important;
    transition: none !important;
  }
}
