/* PWA Mobile - penyesuaian tampilan mobile */

/* ---------- Install banner ---------- */
.pwa-install {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  color: #1e293b;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, .22);
  transform: translateY(30px);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
}
.pwa-install.pwa-show { transform: none; opacity: 1; }
.pwa-install-info { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.35; }
.pwa-install-info strong { font-size: 14px; }
.pwa-install-info span { color: #64748b; }
.pwa-install-actions { display: flex; gap: 6px; flex-shrink: 0; }
.pwa-btn-primary, .pwa-btn-ghost {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.pwa-btn-primary { background: var(--pwa-theme, #2563eb); color: #fff; }
.pwa-btn-ghost { background: transparent; color: #64748b; }

/* ---------- Toast & badge offline ---------- */
.pwa-toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 100001;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 24px);
  padding: 11px 16px;
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  transform: translate(-50%, 20px);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
}
.pwa-toast.pwa-show { transform: translate(-50%, 0); opacity: 1; }
.pwa-toast-btn { background: none; border: 0; color: #93c5fd; font-weight: 700; font-size: 13px; cursor: pointer; padding: 0; }

.pwa-offline-badge {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100001;
  background: #b45309;
  color: #fff;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Bottom navigation ---------- */
.pwa-bottom-nav { display: none; }

@media (max-width: 767px) {
  .pwa-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -2px 12px rgba(15, 23, 42, .06);
    padding-bottom: env(safe-area-inset-bottom);
    /* Layer sendiri di GPU agar tidak ikut bergeser saat scroll / bar alamat Chrome berubah */
    transform: translate3d(0, 0, 0);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    touch-action: manipulation;
    transition: none;
  }
  html { overscroll-behavior-y: none; }
  .pwa-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    color: #64748b;
    font-size: 11px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .pwa-nav-item i { font-size: 20px; line-height: 1; }
  .pwa-nav-item:hover, .pwa-nav-item:focus { color: #64748b; text-decoration: none; }
  .pwa-nav-item.pwa-active { color: var(--pwa-theme, #2563eb); font-weight: 600; }

  body.pwa-has-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.modal-open .pwa-bottom-nav { display: none; }

  /* Penyesuaian kenyamanan sentuh */
  body input[type="text"], body input[type="email"], body input[type="number"], body input[type="password"],
  body input[type="tel"], body input[type="search"], body select, body textarea, body .form-control {
    font-size: 16px; /* mencegah auto-zoom iOS */
  }
  body .btn { min-height: 40px; }
  body .dataTables_wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  body .modal-dialog { margin: 8px; }
  body .content { padding-left: 8px; padding-right: 8px; }
}

/* Mode aplikasi terpasang */
html.pwa-standalone body { overscroll-behavior-y: contain; }
html.pwa-standalone #header { padding-top: env(safe-area-inset-top); }

/* ---------- Tombol install di halaman login ---------- */
.pwa-login-install {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.pwa-login-install > * { pointer-events: auto; }
.pwa-login-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--pwa-theme, #2563eb);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .25);
  cursor: pointer;
}
.pwa-login-install-help {
  max-width: 360px;
  padding: 10px 14px;
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.pwa-debug {
  position: fixed;
  top: 60px;
  left: 8px;
  z-index: 100002;
  margin: 0;
  padding: 6px 8px;
  background: rgba(0, 0, 0, .75);
  color: #7CFC00;
  font: 11px/1.3 monospace;
  border-radius: 6px;
  pointer-events: none;
}
