/* ============================================================
   Dubuz PWA — small screens only (≤767px)
   Larger screens keep the existing desktop / tablet layout.
   Standalone (installed) mode gets extra “native app” chrome.
   ============================================================ */

/* —— Mobile viewport / overscroll (phones & narrow tablets) —— */
@media (max-width: 767px) {
  html {
    height: 100%;
    height: 100dvh;
    overscroll-behavior-y: none;
  }
  body {
    min-height: 100%;
    min-height: 100dvh;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Scroll roots clear fixed tab bar + raised Post FAB */
  .page-content,
  #page-feed,
  #page-marketplace,
  #page-search,
  #page-post-ad,
  #page-messages,
  #page-profile,
  .sng-feed-container > main {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Listing detail uses its own sticky action bar */
  body.sng-listing-immersive .page-content,
  body.sng-listing-immersive .sng-feed-container > main,
  body:has(.ld-mobile-action-bar) .page-content {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .sng-tab-bar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: auto;
    min-height: 50px;
  }

  .dash-content {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .dash-mobile-bar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Full-bleed app shell on narrow viewports */
  .sng-mtopbar {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

/* —— Installed PWA / iOS home-screen (still small-screen only) —— */
@media (max-width: 767px) and (display-mode: standalone) {
  html.pwa-standalone,
  html:has(body.pwa-standalone),
  body.pwa-standalone {
    /* mark for any JS hooks */
  }

  body.pwa-standalone {
    /* No browser chrome — fill the device */
    background: var(--bg-page, #f0f2f5);
  }

  body.pwa-standalone .sng-mtopbar,
  body.pwa-standalone .dash-topbar {
    /* Status bar blends with brand / card */
    background: var(--bg-card, #fff);
  }

  /* Hide “add to home” / install banners once already installed */
  .pwa-install-banner {
    display: none !important;
  }
}

/* iOS Safari “Add to Home Screen” uses standalone too */
@media (max-width: 767px) and (display-mode: fullscreen) {
  body {
    background: var(--bg-page, #f0f2f5);
  }
}

/* —— Desktop / large screens: explicitly leave layout alone —— */
@media (min-width: 768px) {
  .pwa-install-banner {
    display: none !important;
  }
}

/* —— Optional install tip (phones in browser only) —— */
.pwa-install-banner {
  display: none;
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  z-index: 55;
  background: var(--bg-card, #fff);
  color: var(--text-main, #1e293b);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  padding: 16px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  line-height: 1.35;
}
.pwa-install-banner.is-visible {
  display: flex;
}
.pwa-install-banner .pwa-install-copy {
  flex: 1;
  min-width: 0;
}
.pwa-install-banner strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}
.pwa-install-banner span {
  color: var(--text-muted, #64748b);
  font-size: 12px;
}
.pwa-install-banner .pwa-install-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.pwa-install-banner button {
  border: 0;
  border-radius: 10px;
  height: 36px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.pwa-install-banner .pwa-install-go {
  background: var(--primary, #c64949);
  color: #fff;
}
.pwa-install-banner .pwa-install-dismiss {
  background: transparent;
  color: var(--text-muted, #64748b);
}

@media (min-width: 768px) {
  .pwa-install-banner.is-visible {
    display: none !important;
  }
}
