/* ==========================================================
   Penyesuaian aplikasi mobile (PWA): area aman layar, target sentuh,
   dan tampilan saat dibuka dari layar utama (mode standalone).
   ========================================================== */
:root { --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
img, video { max-width: 100%; height: auto; }

/* Header menempel di bawah area status bar (notch / jam HP). */
header.top { padding-top: var(--safe-top); }

/* Footer dan konten bawah tidak tertutup home indicator. */
footer { padding-bottom: calc(var(--safe-bottom) + 12px); }
dialog { padding-bottom: var(--safe-bottom); }

/* Target sentuh minimal 44px (standar iOS/Android). */
@media (pointer: coarse) {
  button, .btn, a.btn, .hero-button, .top-icon, .nav-toggle, .scan-control,
  .officer-login-button, .card-detail-button, .detail-close, .resident-close {
    min-height: 44px;
  }
  .top-icon { min-width: 44px; }
  input, select, textarea { font-size: 16px; } /* cegah zoom otomatis di iOS */
}

/* Tampilan app terpasang (standalone): tanpa kesan browser. */
@media (display-mode: standalone) {
  .scroll-cue { display: none; }
  .hero { padding-top: 24px; }
}

/* Tombol pasang aplikasi. */
.install-app-button {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 60;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: #166534;
  color: #fff;
  font: 600 14px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 10px 30px rgba(22, 101, 52, .35);
  cursor: pointer;
  white-space: nowrap;
}
.install-app-button.is-visible { display: inline-flex; align-items: center; gap: 6px; }
.install-app-button .install-main,
.install-app-button .install-close {
  min-height: 44px;
  border: 0;
  color: #fff;
  background: transparent;
  cursor: pointer;
}
.install-app-button .install-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  font: inherit;
  font-weight: 700;
}
.install-app-button .install-close {
  width: 32px;
  min-width: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

/* Sembunyikan tombol pasang saat sudah terpasang. */
@media (display-mode: standalone) { .install-app-button { display: none !important; } }

/* Mobile app bottom navigation */
.mobile-bottom-nav { display: none; }

@media (max-width: 760px) {
  body { padding-bottom: calc(76px + var(--safe-bottom)); }
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + var(--safe-bottom));
    z-index: 55;
    height: 64px;
    padding: 6px;
    border: 1px solid rgba(187, 247, 208, .9);
    border-radius: 20px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 14px 38px rgba(5, 46, 22, .22);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .mobile-nav-item {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 14px;
    color: #66816f;
    font-size: 9.5px;
    font-weight: 700;
  }
  .mobile-nav-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    font-size: 16px;
  }
  .mobile-nav-item.is-active {
    color: #14532d;
    background: #dcfce7;
  }
  .mobile-nav-item.is-active .mobile-nav-icon {
    background: #166534;
    color: #fff;
  }
  .hero-layout { padding-inline: 2px; }
  .hero-actions { margin-bottom: 4px; }
  .hero-button { border-radius: 15px; }
  .stats { position: relative; z-index: 3; }
  .install-app-button { bottom: calc(82px + var(--safe-bottom)); }
  #residentDialog { background: #f7fdf8; }
}

@media (display-mode: standalone) and (max-width: 760px) {
  body { padding-top: var(--safe-top); }
  header.top { padding-top: 8px; }
}
