/* Buy or Block — PWA: install button, notification bell, mobile tab bar, offline page.
   Uses the design tokens from app.css. Owned by apps/pwa. */

/* ---------- Install button ---------- */
.pwa-install[hidden], .pwa-standalone .pwa-install { display: none !important; }
.pwa-install { color: var(--primary); border-color: var(--primary-100); background: var(--primary-50); }
.pwa-install:hover { background: var(--primary-100); color: var(--primary-700); }

/* ---------- Notification bell ---------- */
.pwa-bell { position: relative; }
.pwa-bell-btn { color: var(--text-2); }
.pwa-bell.open .pwa-bell-btn { background: var(--primary-50); color: var(--primary); }
.pwa-bell-count {
  position: absolute; top: 1px; left: 21px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--red); color: var(--on-status); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  border: 2px solid var(--surface); box-sizing: content-box; font-variant-numeric: tabular-nums;
}
.pwa-bell-count[hidden] { display: none; }
.pwa-bell-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 400px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: none; z-index: 60; overflow: hidden; flex-direction: column;
}
.pwa-bell.open .pwa-bell-panel { display: flex; animation: pwa-pop .14s ease-out; }
@keyframes pwa-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pwa-bell-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.pwa-bell-head strong { font-size: 15px; color: var(--text); }
.pwa-bell-new { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--primary-50); color: var(--primary-700); font-size: 12px; font-weight: 600; line-height: 20px; }
.pwa-bell-new[hidden] { display: none; }
.pwa-link { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--primary); cursor: pointer; }
.pwa-link:hover { color: var(--primary-700); }
.pwa-bell-perm { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--blue-50); color: var(--blue-700); font-size: 13px; border-bottom: 1px solid var(--border); }
.pwa-bell-perm[hidden] { display: none; }
.pwa-bell-perm span { flex: 1; }
.pwa-bell-list { max-height: min(440px, 60vh); overflow-y: auto; overscroll-behavior: contain; }
.pwa-bell-foot { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; border-top: 1px solid var(--border); font-weight: 600; font-size: 13px; background: var(--surface-2); }

/* Notification rows (dropdown + full page) */
.pwa-notif { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; color: var(--text-2); border-bottom: 1px solid var(--border); position: relative; transition: background .12s; }
.pwa-notif:last-child { border-bottom: 0; }
.pwa-notif:hover { background: var(--gray-50); color: var(--text-2); }
.pwa-notif.is-unread { background: var(--accent-tint); }
.pwa-notif.is-unread:hover { background: var(--primary-50); }
.pwa-notif-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--gray-100); color: var(--gray-700); }
.pwa-notif-icon [data-lucide], .pwa-notif-icon svg { width: 18px; height: 18px; }
.pwa-notif-icon.red { background: var(--red-50); color: var(--red-700); }
.pwa-notif-icon.amber { background: var(--amber-50); color: var(--amber-700); }
.pwa-notif-icon.blue { background: var(--blue-50); color: var(--blue-700); }
.pwa-notif-icon.purple { background: var(--purple-50); color: var(--purple-700); }
.pwa-notif-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pwa-notif-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pwa-notif-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pwa-notif-label.red { color: var(--red-700); }
.pwa-notif-label.amber { color: var(--amber-700); }
.pwa-notif-label.blue { color: var(--blue-700); }
.pwa-notif-label.purple { color: var(--purple-700); }
.pwa-notif-top time { font-size: 12px; color: var(--muted-2); white-space: nowrap; }
.pwa-notif-title { font-weight: 600; color: var(--text); line-height: 1.4; overflow-wrap: anywhere; }
.pwa-notif-body { font-size: 13px; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.pwa-notif-body.is-clamped { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pwa-notif-contact { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--primary); }
.pwa-notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 6px; }
.pwa-notif-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 36px 24px; color: var(--muted); font-size: 13px; }
.pwa-notif-empty strong { color: var(--text); font-size: 14px; }
.pwa-notif-empty-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); margin-bottom: 8px; }
.pwa-notif-card { overflow: hidden; padding: 0; }
.pwa-notif-card .pwa-notif { padding: 16px 20px; }
.pwa-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); }

/* ---------- Phones: the bell panel fills the width (the bottom tab bar lives in the app shell) ---------- */
@media (max-width: 760px) {
  .pwa-bell-panel { position: fixed; top: calc(var(--topbar-h) - 4px); left: 8px; right: 8px; width: auto; max-width: none; }
  .pwa-bell-list { max-height: calc(100vh - var(--topbar-h) - 220px); }
  .pwa-install span { display: none; }
  .pwa-install { padding: 7px 9px; }
}

/* ---------- Standalone (installed) tweaks ---------- */
.pwa-standalone body { overscroll-behavior-y: none; }
.pwa-standalone .topbar { padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); }

/* ---------- Offline page ---------- */
.pwa-offline { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 50% 0%, var(--primary-50), var(--bg) 60%); }
.pwa-offline-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 32px 24px; text-align: center; position: relative; }
.pwa-offline-card img { border-radius: 14px; }
.pwa-offline-icon { position: absolute; top: 20px; left: calc(50% + 14px); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--amber-50); color: var(--amber-700); border: 3px solid var(--surface); }
.pwa-offline-icon [data-lucide], .pwa-offline-icon svg { width: 15px; height: 15px; }
.pwa-offline h1 { margin: 20px 0 8px; font-size: 22px; }
.pwa-offline p { color: var(--muted); }
.pwa-offline-tip { font-size: 13px; background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; margin: 16px 0 20px; }
.pwa-offline-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
