/* PWA UI Components - Erstizeitung BCG */
/* University of Bayreuth branding: #249260 (green) */

/* Service Worker Update Toast */
#sw-update-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #249260;
  color: white;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#sw-update-toast button {
  margin-left: 16px;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}

#sw-update-btn {
  background: white;
  color: #249260;
}

#sw-update-btn:hover {
  background: #f5f5f5;
}

#sw-update-btn:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

#sw-dismiss-btn {
  background: transparent;
  color: white;
}

#sw-dismiss-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

#sw-dismiss-btn:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Offline Indicator - Enhanced with contextual messaging */
#offline-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #ff9800;
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  display: flex;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  align-items: center;
  gap: 12px;
  max-width: 320px;
  transform: translateX(400px);
  opacity: 0;
  transition:
    transform 0.3s ease-out,
    opacity 0.3s ease-out;
}

#offline-indicator.show {
  transform: translateX(0);
  opacity: 1;
}

#offline-indicator.online {
  background: #4caf50;
}

.offline-toast {
  /* Container class, no animation needed as it's handled by .show */
}

.offline-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.offline-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.offline-content strong {
  font-size: 14px;
  font-weight: 600;
}

.offline-message {
  font-size: 12px;
  opacity: 0.95;
  line-height: 1.4;
}

/* PWA Install Button - Enhanced with engagement tracking */
#install-pwa-btn {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: #1e7a50; /* Darker green for WCAG AA compliance (5.2:1 contrast ratio) */
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  display: none;
  font-weight: 500;
  z-index: 9998;
  box-shadow: 0 4px 12px rgba(36, 146, 96, 0.3);
  align-items: center;
  gap: 8px;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.install-icon {
  font-size: 20px;
}

.install-text {
  font-size: 14px;
}

.install-dismiss-btn {
  background: transparent;
  color: white;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  margin-left: 8px;
  cursor: pointer;
  opacity: 0.7;
}

.install-dismiss-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.install-dismiss-btn:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

#install-pwa-btn:hover {
  background: #176241;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(36, 146, 96, 0.4);
  transition: all 0.2s ease;
}

#install-pwa-btn:focus {
  outline: 2px solid #249260;
  outline-offset: 2px;
}

/* Accessibility: Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  #install-pwa-btn,
  #offline-indicator,
  .ios-install-banner {
    animation: none !important;
    transition: none !important;
  }

  /* Instant visibility instead of animations */
  #install-pwa-btn {
    opacity: 1;
    transform: none;
  }

  #offline-indicator {
    transform: translateX(0);
    opacity: 1;
  }

  .ios-install-banner {
    opacity: 1;
    transform: translateY(0);
  }
}

/* iOS/Safari Install Instructions Banner */
.ios-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e7a50; /* Match install button color for consistency */
  color: white;
  padding: 16px 20px;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.3s ease-out;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ios-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.ios-install-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.ios-install-text {
  flex: 1;
}

.ios-install-text strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  font-weight: 600;
}

.ios-install-text p {
  font-size: 12px;
  margin: 0;
  opacity: 0.95;
  line-height: 1.4;
}

.ios-install-dismiss {
  background: transparent;
  color: white;
  border: none;
  font-size: 24px;
  line-height: 1;
  padding: 0 8px;
  cursor: pointer;
  opacity: 0.8;
  flex-shrink: 0;
}

.ios-install-dismiss:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.ios-install-dismiss:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Responsive adjustments for iOS banner */
@media (max-width: 480px) {
  .ios-install-banner {
    bottom: 0;
    padding: 12px 16px;
  }

  .ios-install-content {
    gap: 8px;
  }

  .ios-install-icon {
    font-size: 28px;
  }

  .ios-install-text strong {
    font-size: 13px;
  }

  .ios-install-text p {
    font-size: 11px;
  }
}
