/**
 * Service Worker UI Components
 * SG WBO - Styling für Update-Banner, Install-Prompts und Offline-Status
 */

/* ==============================================
   UPDATE BANNER
   ============================================== */

.sw-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideDown 0.3s ease-out;
}

.sw-update-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  gap: 1rem;
}

.sw-update-text {
  flex: 1;
  font-size: 0.95rem;
}

.sw-update-text strong {
  font-weight: 600;
  margin-right: 0.5rem;
}

.sw-update-btn {
  background: white;
  color: #667eea;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sw-update-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.sw-update-btn:active {
  transform: translateY(0);
}

.sw-update-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.sw-update-close:hover {
  opacity: 1;
}

.sw-update-banner.fade-out {
  animation: slideUp 0.3s ease-out forwards;
}

/* ==============================================
   PWA INSTALL BANNER
   ============================================== */

.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: white;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s ease-out reverse;
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

.pwa-install-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

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

.pwa-install-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: #1a202c;
  margin-bottom: 0.25rem;
}

.pwa-install-text small {
  display: block;
  font-size: 0.85rem;
  color: #718096;
}

.pwa-install-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.pwa-install-btn:hover {
  background: #5a67d8;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

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

.pwa-install-close {
  background: transparent;
  border: none;
  color: #a0aec0;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.pwa-install-close:hover {
  color: #4a5568;
}

/* ==============================================
   OFFLINE BANNER
   ============================================== */

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  background: #f56565;
  color: white;
  animation: slideDown 0.3s ease-out;
}

.offline-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}

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

.offline-banner.fade-out {
  animation: slideUp 0.3s ease-out forwards;
}

/* ==============================================
   ANIMATIONS
   ============================================== */

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ==============================================
   MOBILE OPTIMIERUNG
   ============================================== */

@media (max-width: 768px) {

  .sw-update-content,
  .pwa-install-content {
    flex-wrap: wrap;
    padding: 1rem;
  }

  .sw-update-text,
  .pwa-install-text {
    flex-basis: 100%;
    margin-bottom: 0.5rem;
  }

  .sw-update-btn,
  .pwa-install-btn {
    flex: 1;
    padding: 0.7rem 1rem;
    font-size: 0.85rem;
  }

  .pwa-install-content {
    padding: 0.875rem 1rem;
  }

  .pwa-install-icon {
    width: 40px;
    height: 40px;
  }

  .offline-content {
    font-size: 0.85rem;
    padding: 0.625rem 1rem;
  }
}

@media (max-width: 480px) {
  .sw-update-content {
    padding: 0.875rem;
  }

  .sw-update-text strong {
    display: block;
    margin-bottom: 0.25rem;
  }

  .pwa-install-text strong {
    font-size: 0.95rem;
  }

  .pwa-install-text small {
    font-size: 0.8rem;
  }
}

/* ==============================================
   LOADING SPINNER (Optional)
   ============================================== */

.sw-loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.6s linear infinite;
  margin-left: 0.5rem;
  vertical-align: middle;
}

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

/* ==============================================
   STANDALONE MODE (PWA installiert)
   ============================================== */

@media (display-mode: standalone) {

  /* Verstecke Install-Banner wenn App installiert ist */
  .pwa-install-banner {
    display: none !important;
  }

  /* Optional: Mehr Padding oben wenn kein Browser-UI */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ==============================================
   DARK MODE SUPPORT
   ============================================== */

@media (prefers-color-scheme: dark) {
  .pwa-install-banner {
    background: #2d3748;
  }

  .pwa-install-text strong {
    color: #f7fafc;
  }

  .pwa-install-text small {
    color: #cbd5e0;
  }

  .pwa-install-close {
    color: #718096;
  }

  .pwa-install-close:hover {
    color: #cbd5e0;
  }
}

/* ==============================================
   ACCESSIBILITY
   ============================================== */

.sw-update-btn:focus,
.pwa-install-btn:focus,
.sw-update-close:focus,
.pwa-install-close:focus {
  outline: 2px solid #4299e1;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

  .sw-update-banner,
  .pwa-install-banner,
  .offline-banner {
    animation: none;
  }

  .sw-update-btn,
  .pwa-install-btn {
    transition: none;
  }
}

/* ==============================================
   PRINT MODE
   ============================================== */

@media print {

  .sw-update-banner,
  .pwa-install-banner,
  .offline-banner {
    display: none !important;
  }
}