/**
 * PWA UI Components CSS (2026 Standards).
 * Install prompts, update notifications, offline banners.
 */

/* Install Button (in header/footer) */
#install-btn {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: #d4af37;
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

#install-btn:hover {
  background: #b8941f;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

#install-btn::before {
  content: '📱';
  font-size: 1.125rem;
}

/* Update Banner */
.pwa-update-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s ease-out;
}

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

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

.pwa-update-content span {
  flex: 1 1 auto;
  font-weight: 600;
  font-size: 0.9rem;
}

.pwa-update-btn {
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 700;
  background: white;
  color: #667eea;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.pwa-update-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.3);
}

.pwa-dismiss-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  background: transparent;
  color: white;
  border: none;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.pwa-dismiss-btn:hover {
  opacity: 1;
}

/* Offline Banner */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.3s ease-out;
}

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

/* Install Prompt Card (optional inline prompt) */
.pwa-install-card {
  margin: 2rem 0;
  padding: 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.pwa-install-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.pwa-install-card p {
  margin: 0 0 1.5rem;
  opacity: 0.95;
}

.pwa-install-card .benefits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  text-align: left;
}

.pwa-install-card .benefit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.pwa-install-card .benefit::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-weight: 700;
}

.pwa-install-card button {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 700;
  background: white;
  color: #667eea;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pwa-install-card button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 255, 255, 0.3);
}

/* iOS Install Instructions */
.ios-install-guide {
  display: none;
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--flatbg, #f9fafb);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 12px;
}

.ios-install-guide h4 {
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ios-install-guide ol {
  margin: 0;
  padding-left: 1.5rem;
}

.ios-install-guide li {
  margin: 0.5rem 0;
  line-height: 1.6;
}

/* Show iOS guide on iOS devices */
@supports (-webkit-touch-callout: none) {
  .ios-install-guide {
    display: block;
  }
}

/* Standalone mode adjustments */
@media (display-mode: standalone) {
  /* Hide browser chrome elements */
  #install-btn {
    display: none !important;
  }
  
  /* Add safe area insets */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  /* Adjust header for notch */
  header {
    padding-top: calc(1rem + env(safe-area-inset-top));
  }
}

/* Mobile specific */
@media (max-width: 640px) {
  .pwa-update-content {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  
  .pwa-update-btn {
    width: 100%;
  }
  
  .pwa-install-card .benefits {
    grid-template-columns: 1fr;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pwa-update-banner,
  .offline-banner {
    animation: none;
  }
  
  #install-btn:hover,
  .pwa-update-btn:hover,
  .pwa-install-card button:hover {
    transform: none;
  }
}

/* High contrast */
@media (prefers-contrast: high) {
  .pwa-update-banner,
  .offline-banner,
  .pwa-install-card {
    border: 2px solid currentColor;
  }
}
