/* ==========================================================================
   PWA INSTALL PROMPT - NATIVE MOBILE ONBOARDING UX
   ========================================================================== */

#pwaInstallPrompt {
  position: fixed;
  bottom: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  z-index: 999999;
  max-width: 420px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.28), 0 8px 18px rgba(0, 0, 0, 0.08), inset 0 1px 0 #ffffff;
  padding: 14px 16px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: #1d1d1f;
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

/* Fly-in active state */
#pwaInstallPrompt.pwa-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Fly-out exit state */
#pwaInstallPrompt.pwa-hiding {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.4, 0, 1, 1), opacity 0.25s ease;
}

/* Prompt Card Inner Layout */
.pwa-install-body {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

/* App Icon Squircle */
.pwa-install-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.pwa-install-icon img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

/* Text Content */
.pwa-install-content {
  flex: 1;
  min-width: 0;
  padding-right: 18px; /* space for close button */
}

.pwa-install-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  color: #1c1c1e;
  margin: 0;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-install-description {
  font-size: 0.77rem;
  font-weight: 400;
  line-height: 1.35;
  color: #636366;
  margin-top: 3px;
}

/* Action Button */
.pwa-install-action {
  flex-shrink: 0;
}

#btnPwaInstall {
  background: #184e3b;
  color: #ffffff !important;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(24, 78, 59, 0.35);
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  outline: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

#btnPwaInstall:hover {
  background: #103829;
  transform: scale(1.03);
  box-shadow: 0 6px 16px rgba(24, 78, 59, 0.45);
}

#btnPwaInstall:active {
  transform: scale(0.96);
}

/* Close Button (×) */
.pwa-install-close {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: #8e8e93;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  padding: 0;
  outline: none !important;
}

.pwa-install-close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #1c1c1e;
  transform: scale(1.1);
}

/* ==========================================================================
   iOS STEP-BY-STEP GUIDE ACCORDION / OVERLAY
   ========================================================================== */

.pwa-ios-guide {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.82rem;
  color: #3a3a3c;
  animation: fadeIn 0.3s ease;
}

.pwa-ios-guide-header {
  font-weight: 700;
  margin-bottom: 8px;
  color: #184e3b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pwa-ios-steps {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pwa-ios-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  line-height: 1.35;
}

.pwa-step-num {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  background: #184e3b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-ios-icon-share {
  display: inline-flex;
  vertical-align: middle;
  color: #007aff;
  margin: 0 2px;
}

/* ==========================================================================
   DESKTOP / WIDE SCREENS BEHAVIOR
   ========================================================================== */

@media (min-width: 768px) {
  #pwaInstallPrompt {
    left: auto;
    right: 24px;
    bottom: 24px;
    max-width: 390px;
    margin: 0;
  }
}

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