/* ============================================================
   PWA LAYER — Splash, Install, Update Popup, Offline Banner
   Glassmorphism + Neon. Dibuat ringan (GPU-friendly, no reflow).
   ============================================================ */

:root {
  --pwa-accent: #00f3ff;
  --pwa-bg: #05060d;
}

/* ---------------- Splash Screen ---------------- */
#pwa-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background:
    radial-gradient(60% 45% at 50% 30%, color-mix(in srgb, var(--pwa-accent) 16%, transparent), transparent 70%),
    var(--pwa-bg);
  opacity: 1;
  transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.45s;
  will-change: opacity;
  contain: strict;
  -webkit-tap-highlight-color: transparent;
}

#pwa-splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pwa-splash-ring {
  position: relative;
  width: 168px;
  height: 168px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 0 42px color-mix(in srgb, var(--pwa-accent) 32%, transparent),
    inset 0 0 26px rgba(255, 255, 255, 0.06);
}

.pwa-splash-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.pwa-splash-ring .track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 5;
}

.pwa-splash-ring .bar {
  fill: none;
  stroke: var(--pwa-accent);
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--pwa-accent));
  transition: stroke-dashoffset 0.18s linear;
}

.pwa-splash-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  border-radius: 22px;
  animation: pwa-breathe 2.6s ease-in-out infinite;
}

@keyframes pwa-breathe {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.06); opacity: 1; }
}

.pwa-splash-meta {
  text-align: center;
  color: #e8ecff;
  font-family: "Outfit", "Segoe UI", system-ui, sans-serif;
}

.pwa-splash-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.pwa-splash-percent {
  font-size: 2rem;
  font-weight: 800;
  color: var(--pwa-accent);
  text-shadow: 0 0 18px color-mix(in srgb, var(--pwa-accent) 55%, transparent);
  font-variant-numeric: tabular-nums;
  margin: 0.35rem 0 0;
}

.pwa-splash-sub {
  font-size: 0.72rem;
  color: #8f9bc4;
  margin: 0.2rem 0 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------------- Tombol Install ---------------- */
.pwa-install-btn {
  position: fixed;
  right: 1rem;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 5.4rem);
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.05rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--pwa-accent) 55%, transparent);
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(14px);
  color: #e8ecff;
  font: 600 0.82rem/1 "Outfit", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 0 22px color-mix(in srgb, var(--pwa-accent) 30%, transparent);
  animation: pwa-pop 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.pwa-install-btn:active { transform: scale(0.96); }
.pwa-install-btn svg { width: 17px; height: 17px; }

@media (min-width: 1024px) {
  .pwa-install-btn { bottom: 1.5rem; }
}

@keyframes pwa-pop {
  from { opacity: 0; transform: translateY(14px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* ---------------- Popup Update ---------------- */
.pwa-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.1rem;
  background: rgba(3, 5, 12, 0.72);
  backdrop-filter: blur(9px);
  animation: pwa-fade 0.28s ease-out;
}

.pwa-modal.is-out { animation: pwa-fade 0.24s ease-in reverse; }

@keyframes pwa-fade { from { opacity: 0; } to { opacity: 1; } }

.pwa-modal-card {
  position: relative;
  width: min(420px, 100%);
  padding: 1.6rem 1.35rem 1.35rem;
  text-align: center;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(22px);
  border: 1px solid color-mix(in srgb, var(--pwa-accent) 45%, transparent);
  box-shadow:
    0 0 38px color-mix(in srgb, var(--pwa-accent) 26%, transparent),
    0 22px 60px rgba(0, 0, 0, 0.6);
  color: #e8ecff;
  animation: pwa-rise 0.34s cubic-bezier(0.34, 1.3, 0.64, 1);
  max-height: 90dvh;
  overflow-y: auto;
}

@keyframes pwa-rise {
  from { opacity: 0; transform: translateY(22px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.pwa-modal-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 18px;
  margin: 0 auto 0.9rem;
  display: block;
  box-shadow: 0 0 24px color-mix(in srgb, var(--pwa-accent) 40%, transparent);
}

.pwa-modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--pwa-accent);
  text-shadow: 0 0 16px color-mix(in srgb, var(--pwa-accent) 45%, transparent);
}

.pwa-modal-version {
  display: inline-block;
  margin: 0.55rem 0 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.pwa-modal-note {
  margin: 0 0 1.1rem;
  font-size: 0.83rem;
  line-height: 1.6;
  color: #b9c3e6;
  white-space: pre-line;
  text-align: left;
  max-height: 34dvh;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pwa-modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.pwa-btn {
  flex: 1 1 auto;
  min-width: 130px;
  min-height: 46px;
  padding: 0 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecff;
  font: 700 0.86rem/1 "Outfit", system-ui, sans-serif;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.pwa-btn:active { transform: scale(0.97); }

.pwa-btn-primary {
  border-color: color-mix(in srgb, var(--pwa-accent) 65%, transparent);
  background: color-mix(in srgb, var(--pwa-accent) 16%, transparent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--pwa-accent) 32%, transparent);
}

/* ---------------- Banner Offline ---------------- */
.pwa-net-banner {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 0.6rem);
  transform: translate(-50%, -160%);
  z-index: 9400;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font: 600 0.76rem/1 "Outfit", system-ui, sans-serif;
  color: #ffdede;
  background: rgba(255, 45, 85, 0.16);
  border: 1px solid rgba(255, 45, 85, 0.5);
  backdrop-filter: blur(12px);
  box-shadow: 0 0 20px rgba(255, 45, 85, 0.28);
  transition: transform 0.32s cubic-bezier(0.34, 1.3, 0.64, 1);
  white-space: nowrap;
}

.pwa-net-banner.show { transform: translate(-50%, 0); }

.pwa-net-banner.online {
  color: #d8ffe4;
  background: rgba(57, 255, 20, 0.14);
  border-color: rgba(57, 255, 20, 0.45);
  box-shadow: 0 0 20px rgba(57, 255, 20, 0.25);
}

/* ---------------- Halaman Offline ---------------- */
.pwa-offline-body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 40% at 50% 20%, rgba(0, 243, 255, 0.12), transparent 70%),
    #05060d;
  color: #e8ecff;
  font-family: "Outfit", "Segoe UI", system-ui, sans-serif;
}

.pwa-offline { padding: 1.25rem; width: 100%; }

.pwa-offline-card {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  text-align: center;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.pwa-offline-card h1 { font-size: 1.15rem; margin: 0 0 0.6rem; }
.pwa-offline-card p { font-size: 0.85rem; color: #8f9bc4; line-height: 1.6; margin: 0 0 1rem; }

.pwa-offline-icon {
  width: 74px;
  height: 74px;
  margin: 0 auto 1.1rem;
  color: #00f3ff;
  filter: drop-shadow(0 0 14px rgba(0, 243, 255, 0.5));
}

.pwa-offline-icon svg { width: 100%; height: 100%; }

.pwa-offline-status {
  font-size: 0.75rem;
  color: #8f9bc4;
  margin-bottom: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------------- Aksesibilitas & performa ---------------- */
@media (prefers-reduced-motion: reduce) {
  #pwa-splash,
  .pwa-splash-logo,
  .pwa-modal,
  .pwa-modal-card,
  .pwa-install-btn {
    animation: none !important;
    transition-duration: 0.001ms !important;
  }
}

html.pwa-locked,
body.pwa-locked { overflow: hidden !important; }


/* Catatan update wajib (hitung mundur auto-redirect) */
.pwa-modal-hint {
  margin: .35rem 0 0;
  font-size: .72rem;
  letter-spacing: .02em;
  color: color-mix(in srgb, var(--pwa-neon, #00f3ff) 82%, #fff);
  text-shadow: 0 0 12px color-mix(in srgb, var(--pwa-neon, #00f3ff) 45%, transparent);
}


/* Panel hasil mode pengujian offline (?pwa_test=offline) */
.pwa-test-log {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  z-index: 2147483000;
  max-height: 46vh;
  overflow: auto;
  margin: 0;
  padding: .85rem 1rem;
  border-radius: 14px;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  color: #d8fbff;
  background: rgba(6, 10, 22, .78);
  backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, var(--pwa-neon, #00f3ff) 45%, transparent);
  box-shadow: 0 0 26px color-mix(in srgb, var(--pwa-neon, #00f3ff) 22%, transparent);
}
