/* PWA install banner — YouTube-style prompt */
.pwa-install-banner {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(110%);
  z-index: 10050;
  width: min(520px, calc(100vw - 24px));
  margin-bottom: max(16px, env(safe-area-inset-bottom));
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.pwa-install-banner.pwa-install-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.pwa-install-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
}

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

.pwa-install-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pwa-install-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
}

.pwa-install-sub {
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.35;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pwa-install-btn {
  border: none;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 2;
}

.pwa-install-btn:hover {
  background: #1d4ed8;
}

.pwa-install-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.pwa-install-banner.pwa-install-visible,
.pwa-install-banner:not([hidden]) {
  pointer-events: auto;
}

.pwa-install-inner {
  pointer-events: auto;
}

/* Manual install help sheet */
.pwa-install-help {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.pwa-install-help.pwa-install-visible {
  opacity: 1;
  pointer-events: auto;
}

.pwa-install-help[hidden] {
  display: none !important;
}

.pwa-install-help:not([hidden]) {
  display: flex;
}

.pwa-install-help-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 1.1rem 1.15rem 1.15rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
  position: relative;
}

.pwa-install-help-card h3 {
  margin: 0 2rem 0.75rem 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.pwa-install-help-body {
  color: #334155;
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}

.pwa-install-help-body ol {
  margin: 0;
  padding-left: 1.2rem;
}

.pwa-install-help-body li {
  margin-bottom: 0.45rem;
}

.pwa-help-note {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: #64748b;
}

.pwa-install-help-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
}

.pwa-install-help-ok {
  width: 100%;
  justify-content: center;
}

.pwa-install-dismiss {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.pwa-install-dismiss:hover {
  background: #f1f5f9;
  color: #475569;
}

/* iOS add-to-home hint */
.pwa-ios-hint {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(110%);
  z-index: 10051;
  width: min(400px, calc(100vw - 24px));
  margin-bottom: max(16px, env(safe-area-inset-bottom));
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.pwa-ios-hint.pwa-install-visible {
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.pwa-ios-hint-inner {
  position: relative;
  padding: 14px 40px 14px 16px;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 14px;
  font-size: 0.85rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.pwa-ios-hint-inner .pwa-install-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #94a3b8;
}

.pwa-ios-share {
  display: inline-block;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-weight: 600;
}

@media (min-width: 768px) {
  .pwa-install-banner {
    left: auto;
    right: 24px;
    bottom: 24px;
    transform: translateY(110%);
    margin-bottom: 0;
  }

  .pwa-install-banner.pwa-install-visible {
    transform: translateY(0);
  }

  .pwa-ios-hint {
    left: auto;
    right: 24px;
    bottom: 24px;
    transform: translateY(110%);
    margin-bottom: 0;
  }

  .pwa-ios-hint.pwa-install-visible {
    transform: translateY(0);
  }
}

/* Ensure [hidden] does not fight visibility class on mobile browsers */
.pwa-install-banner[hidden],
.pwa-ios-hint[hidden] {
  display: none !important;
}

.pwa-install-banner:not([hidden]),
.pwa-ios-hint:not([hidden]) {
  display: block;
}

@media (max-width: 767.98px) {
  .pwa-install-banner {
    width: calc(100vw - 16px);
    margin-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .pwa-install-inner {
    gap: 10px;
    padding: 12px 12px;
  }

  .pwa-install-title {
    font-size: 0.9rem;
  }

  .pwa-install-sub {
    font-size: 0.75rem;
  }

  .pwa-install-btn {
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-install-banner,
  .pwa-ios-hint {
    transition: none;
  }
}
