/**
 * Enterprise PWA UI Component Styles
 * Mtandao Publishers (mtandaopublishers.co.ke)
 */

/* ── 1. Header Install App Button ─────────────────────────────────────────── */
.pwa-header-install-btn {
  display: inline-flex; /* Visible by default on all devices */
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  color: #ffffff !important;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.95rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(4, 120, 87, 0.25);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}

.pwa-header-install-btn:hover {
  background: linear-gradient(135deg, #065f46 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.35);
  color: #ffffff !important;
}

.pwa-header-install-btn i {
  font-size: 0.95rem;
  animation: pwaBounce 2.5s infinite;
}

@keyframes pwaBounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-3px); }
  60% { transform: translateY(-1.5px); }
}

@media (max-width: 768px) {
  .pwa-header-install-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
  }
}

/* ── 2. Floating Bottom Install Banner / Sheet ───────────────────────────── */
.pwa-install-banner {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(160%);
  width: calc(100% - 2rem);
  max-width: 480px;
  background: #ffffff;
  border: 1px solid rgba(4, 120, 87, 0.2);
  border-radius: 16px;
  box-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(4, 120, 87, 0.12);
  padding: 0.9rem 1.15rem;
  z-index: 100002 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.pwa-install-banner.pwa-banner-visible {
  transform: translateX(-50%) translateY(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
}

.pwa-banner-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 0;
}

.pwa-banner-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.pwa-banner-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pwa-banner-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #111827;
  line-height: 1.25;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-desc {
  font-size: 0.76rem;
  color: #4b5563;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.pwa-btn-install {
  background: #047857;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background-color 0.2s, transform 0.15s;
  white-space: nowrap;
}

.pwa-btn-install:hover {
  background: #065f46;
  transform: translateY(-1px);
}

.pwa-btn-close {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background-color 0.2s;
  font-size: 1.15rem;
}

.pwa-btn-close:hover {
  color: #111827;
  background-color: #f3f4f6;
}

/* Mobile responsive adjustments for floating banner */
@media (max-width: 640px) {
  .pwa-install-banner {
    /* Float above the WhatsApp button (which sits at bottom: 1.25rem; right: 4.75rem) */
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
    width: calc(100% - 1.25rem);
    padding: 0.75rem 0.85rem;
    border-radius: 14px;
    gap: 0.6rem;
  }

  .pwa-banner-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
  }

  .pwa-banner-title {
    font-size: 0.88rem;
  }

  .pwa-banner-desc {
    font-size: 0.72rem;
    max-width: 160px;
  }

  .pwa-btn-install {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 370px) {
  .pwa-banner-desc {
    display: none; /* Hide subtitle on very small screens to keep layout clean */
  }
}

/* ── 3. Instructions Modals (iOS & Android) ───────────────────────────────── */
.pwa-ios-modal-overlay,
.pwa-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(17, 24, 39, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100010 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.pwa-ios-modal-overlay.pwa-modal-active,
.pwa-modal-overlay.pwa-modal-active {
  display: flex !important;
  animation: pwaFadeIn 0.25s ease-out;
}

@keyframes pwaFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.pwa-ios-modal-card,
.pwa-modal-card {
  background: #ffffff;
  border-radius: 18px;
  max-width: 420px;
  width: 100%;
  padding: 1.75rem 1.5rem;
  position: relative;
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.pwa-ios-modal-header,
.pwa-modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.25rem;
}

.pwa-ios-modal-icon,
.pwa-modal-icon {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.25);
  margin-bottom: 0.85rem;
  object-fit: contain;
}

.pwa-ios-modal-title,
.pwa-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.35rem;
}

.pwa-ios-modal-sub,
.pwa-modal-sub {
  font-size: 0.85rem;
  color: #4b5563;
  line-height: 1.4;
}

.pwa-ios-steps,
.pwa-modal-steps {
  list-style: none;
  text-align: left;
  margin: 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0;
}

.pwa-ios-step,
.pwa-modal-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  font-size: 0.86rem;
  color: #1f2937;
  line-height: 1.4;
}

.pwa-ios-step-num,
.pwa-modal-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #047857;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.pwa-ios-step i,
.pwa-modal-step i {
  color: #047857;
  font-size: 1.1rem;
}

.pwa-ios-modal-close,
.pwa-modal-close-btn {
  width: 100%;
  background: #047857;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background-color 0.2s;
}

.pwa-ios-modal-close:hover,
.pwa-modal-close-btn:hover {
  background: #065f46;
}

/* ── 4. Live Network Status Toast ────────────────────────────────────────── */
.pwa-toast {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  background: #111827;
  color: #ffffff;
  padding: 0.65rem 1.15rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  z-index: 100020 !important;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.pwa-toast.pwa-toast-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.pwa-toast-offline {
  background: #b91c1c;
}

.pwa-toast-online {
  background: #047857;
}

.pwa-toast-update {
  background: #1e3a8a;
  border-radius: 14px;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.85rem 1.15rem;
  gap: 0.6rem;
  max-width: 360px;
}

.pwa-toast-update-btn {
  background: #ffffff;
  color: #1e3a8a;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-end;
}

/* Hide all install prompts when app is already installed & running standalone */
body.is-pwa-standalone .pwa-header-install-btn,
body.is-pwa-standalone .pwa-install-banner,
body.is-pwa-standalone .pwa-ios-modal-overlay,
body.is-pwa-standalone .pwa-modal-overlay {
  display: none !important;
}
