/* ==========================================================
   VextaLearn — PWA UI layer
   Install FAB / modal, first-launch welcome, connectivity
   banner, update toast, and safe-area handling for notched
   devices. Kept separate from main.css on purpose so the PWA
   layer can be iterated on without touching page styles.
   ========================================================== */

:root {
  --vxt-safe-top: env(safe-area-inset-top, 0px);
  --vxt-safe-bottom: env(safe-area-inset-bottom, 0px);
  --vxt-safe-left: env(safe-area-inset-left, 0px);
  --vxt-safe-right: env(safe-area-inset-right, 0px);
}

body {
  padding-left: var(--vxt-safe-left);
  padding-right: var(--vxt-safe-right);
}

/* Notch/status-bar inset belongs on the sticky header itself, not on
   body — applying it to body pushed the entire page down and left a
   blank gap above the navbar once it stuck to the top on scroll. */
.vxt-navbar {
  padding-top: var(--vxt-safe-top);
}

/* Admin pages hide the public navbar (see mobile-ui.css), so they need
   the top inset restored directly on body to clear notches/status bars. */
body.admin-body {
  padding-top: var(--vxt-safe-top);
}

/* Standalone-only chrome: e.g. hide "install" affordances once installed */
html.vxt-installed .vxt-install-fab { display: none !important; }

/* ---------- Install FAB ---------- */
.vxt-install-fab {
  position: fixed;
  right: calc(20px + var(--vxt-safe-right));
  bottom: calc(20px + var(--vxt-safe-bottom));
  z-index: 1040;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #6D38E8, #17A3E8);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(108, 99, 255, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.vxt-install-fab:active { transform: scale(0.95); }
.vxt-install-fab[hidden] { display: none; }

/* ---------- Install modal ---------- */
.vxt-install-modal {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.vxt-install-modal--visible { opacity: 1; pointer-events: auto; }
.vxt-install-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 16, 53, 0.55);
  backdrop-filter: blur(2px);
}
.vxt-install-modal__sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 28px 24px calc(28px + var(--vxt-safe-bottom));
  text-align: center;
  transform: translateY(12px);
  transition: transform 0.2s ease;
}
.vxt-install-modal--visible .vxt-install-modal__sheet { transform: translateY(0); }
@media (min-width: 640px) {
  .vxt-install-modal { align-items: center; }
  .vxt-install-modal__sheet { border-radius: 24px; }
}
.vxt-install-modal__icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 16px;
}
.vxt-install-modal__sheet h3 { font-weight: 700; margin-bottom: 8px; }
.vxt-install-modal__sheet p { color: #6b7280; font-size: 0.9rem; margin-bottom: 20px; }
.vxt-install-modal__actions {
  display: flex;
  gap: 12px;
}
.vxt-install-modal__actions .vxt-btn-secondary,
.vxt-install-modal__actions .vxt-btn-primary {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
}
.vxt-install-modal__actions .vxt-btn-secondary { background: #f3f4f6; color: #374151; }
.vxt-install-modal__actions .vxt-btn-primary { background: linear-gradient(135deg, #6D38E8, #17A3E8); color: #fff; }

/* ---------- First-launch welcome ---------- */
.vxt-welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  padding-top: calc(24px + var(--vxt-safe-top));
  padding-bottom: calc(24px + var(--vxt-safe-bottom));
  background: linear-gradient(160deg, #6D38E8, #17A3E8);
  color: #fff;
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.vxt-welcome-screen--visible { opacity: 1; }
.vxt-welcome-screen__icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  margin-bottom: 8px;
}
.vxt-welcome-screen h2 { font-weight: 700; margin: 0; }
.vxt-welcome-screen p { opacity: 0.9; max-width: 320px; margin: 0 0 8px; }
.vxt-welcome-screen .vxt-btn-primary {
  background: #fff;
  color: #4f46e5;
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Connectivity banner ---------- */
.vxt-connectivity-banner {
  position: fixed;
  top: calc(0px + var(--vxt-safe-top));
  left: 0;
  right: 0;
  z-index: 1070;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 16px;
  background: #f59e0b;
  color: #fff;
  transform: translateY(-100%);
  transition: transform 0.25s ease;
}
.vxt-connectivity-banner--visible { transform: translateY(0); }
.vxt-connectivity-banner--online { background: #10b981; }

/* ---------- Push opt-in banner ---------- */
.vxt-push-optin {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(76px + var(--vxt-safe-bottom));
  z-index: 1075;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1A1035;
  color: #fff;
  padding: 14px 16px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transform: translateY(140%);
  transition: transform 0.25s ease;
}
.vxt-push-optin--visible { transform: translateY(0); }
.vxt-push-optin i { color: #6D38E8; font-size: 1.1rem; flex-shrink: 0; }
.vxt-push-optin span { flex: 1; font-size: 0.82rem; line-height: 1.3; }
.vxt-push-optin .vxt-btn-primary {
  background: #6D38E8;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.vxt-push-optin__close {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
@media (min-width: 992px) {
  .vxt-push-optin { left: auto; right: 20px; bottom: 20px; max-width: 360px; }
}

/* ---------- Update toast ---------- */
.vxt-update-toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--vxt-safe-bottom));
  transform: translate(-50%, 120%);
  z-index: 1080;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1A1035;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transition: transform 0.25s ease;
  max-width: calc(100vw - 32px);
}
.vxt-update-toast--visible { transform: translate(-50%, 0); }
.vxt-update-toast__btn {
  background: #6D38E8;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
