/* ============================================================
   PPI Alumni — shared app UI (batch 25)
   Loaded by the website layout AND the admin panel layout:
     1. Toast notifications (replace the full-width flash bars)
     2. "Install app" buttons, card and the how-to sheet
     3. App mode (installed, standalone): safe areas + bottom tab bar
   Own class prefix (.ppi-) so nothing here collides with style.css or
   admin.css.
   ============================================================ */
:root {
    --ppi-ui-navy: #0b1f4b;
    --ppi-ui-ink: #0f172a;
    --ppi-ui-text: #334155;
    --ppi-ui-muted: #64748b;
    --ppi-ui-card: #ffffff;
    --ppi-ui-line: rgba(15, 23, 42, 0.08);
    --ppi-ui-gold: #fbbf24;
    --ppi-ui-ok: #16a34a;
    --ppi-ui-ok-bg: #dcfce7;
    --ppi-ui-bad: #dc2626;
    --ppi-ui-bad-bg: #fee2e2;
    --ppi-ui-warn: #d97706;
    --ppi-ui-warn-bg: #fef3c7;
    --ppi-ui-info: #2563eb;
    --ppi-ui-info-bg: #dbeafe;
    --ppi-ui-font: 'Inter', 'Noto Sans Bengali', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    --ppi-tabbar-h: 0px;
}
html.admin-dark {
    --ppi-ui-ink: #e6edf7;
    --ppi-ui-text: #c5cfdd;
    --ppi-ui-muted: #94a3b8;
    --ppi-ui-card: #162038;
    --ppi-ui-line: rgba(255, 255, 255, 0.1);
}

/* ---------------- 1. toasts ---------------- */
.ppi-toasts {
    position: fixed; z-index: 4000; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom, 0px) + var(--ppi-tabbar-h));
    display: flex; flex-direction: column-reverse; gap: 12px; width: min(420px, calc(100vw - 32px));
    pointer-events: none; font-family: var(--ppi-ui-font);
}
.ppi-toast {
    --ppi-tone: var(--ppi-ui-info); --ppi-tone-bg: var(--ppi-ui-info-bg);
    position: relative; pointer-events: auto; display: grid; grid-template-columns: 40px minmax(0, 1fr) 30px; gap: 12px; align-items: start;
    padding: 14px 12px 16px 14px; border-radius: 16px; overflow: hidden;
    background: var(--ppi-ui-card); color: var(--ppi-ui-text);
    border: 1px solid var(--ppi-ui-line);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 22px 48px -18px rgba(11, 31, 75, 0.38);
    animation: ppi-toast-in .38s cubic-bezier(.2, .9, .25, 1.15) both;
}
.ppi-toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ppi-tone); }
.ppi-toast--success { --ppi-tone: var(--ppi-ui-ok); --ppi-tone-bg: var(--ppi-ui-ok-bg); }
.ppi-toast--error { --ppi-tone: var(--ppi-ui-bad); --ppi-tone-bg: var(--ppi-ui-bad-bg); }
.ppi-toast--warning { --ppi-tone: var(--ppi-ui-warn); --ppi-tone-bg: var(--ppi-ui-warn-bg); }
html.admin-dark .ppi-toast { --ppi-tone-bg: rgba(255, 255, 255, 0.08); }
.ppi-toast__icon {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
    background: var(--ppi-tone-bg); color: var(--ppi-tone); font-size: 18px;
}
.ppi-toast__body { min-width: 0; padding-top: 1px; }
.ppi-toast__title { display: block; font-size: 14.5px; font-weight: 700; color: var(--ppi-ui-ink); line-height: 1.35; margin: 0 0 2px; }
.ppi-toast__text { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ppi-ui-text); overflow-wrap: anywhere; }
.ppi-toast__text + .ppi-toast__text { margin-top: 4px; }
.ppi-toast__list { margin: 4px 0 0; padding: 0 0 0 18px; font-size: 13px; line-height: 1.55; }
.ppi-toast__close {
    appearance: none; border: 0; background: transparent; color: var(--ppi-ui-muted); cursor: pointer;
    width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; margin-top: -2px;
}
.ppi-toast__close:hover, .ppi-toast__close:focus-visible { background: rgba(100, 116, 139, 0.12); color: var(--ppi-ui-ink); outline: none; }
.ppi-toast__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--ppi-tone); opacity: .35; transform-origin: left center; }
/* duration is set inline from data-timeout; the bar's animationend closes the toast,
   so hovering (which pauses the animation) also pauses the countdown. */
.ppi-toast[data-timeout] .ppi-toast__bar { animation-name: ppi-toast-bar; animation-timing-function: linear; animation-fill-mode: forwards; }
.ppi-toast:hover .ppi-toast__bar, .ppi-toast:focus-within .ppi-toast__bar, .ppi-toast.is-paused .ppi-toast__bar { animation-play-state: paused; }
.ppi-toast.is-leaving { animation: ppi-toast-out .28s ease forwards; }
@keyframes ppi-toast-in { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes ppi-toast-out { to { opacity: 0; transform: translateX(28px); } }
@keyframes ppi-toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 640px) {
    .ppi-toasts { left: 12px; right: 12px; width: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--ppi-tabbar-h)); }
    .ppi-toast { grid-template-columns: 36px minmax(0, 1fr) 28px; padding: 12px 10px 14px 12px; border-radius: 14px; }
    .ppi-toast__icon { width: 36px; height: 36px; font-size: 16px; border-radius: 10px; }
    @keyframes ppi-toast-out { to { opacity: 0; transform: translateY(16px); } }
}
@media (prefers-reduced-motion: reduce) {
    .ppi-toast, .ppi-toast.is-leaving { animation-duration: .01s; }
}

/* ---------------- 2. install ---------------- */
[data-pwa-install][hidden], .ppi-install-card[hidden] { display: none !important; }
@media (display-mode: standalone), (display-mode: minimal-ui) {
    [data-pwa-install], .ppi-install-card { display: none !important; }
}

/* footer pill: logo · "Install app / Phone · Tablet · PC" · download */
.ppi-install-pill {
    appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 10px;
    margin-top: 16px; padding: 7px 14px 7px 7px; border-radius: 14px; font-family: var(--ppi-ui-font);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.28), rgba(13, 148, 136, 0.18));
    border: 1px solid rgba(255, 255, 255, 0.18); color: #fff; text-align: left;
    box-shadow: 0 10px 26px -14px rgba(0, 0, 0, 0.6); transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.ppi-install-pill:hover, .ppi-install-pill:focus-visible { transform: translateY(-2px); border-color: rgba(251, 191, 36, 0.7); outline: none; }
.ppi-install-pill__logo { width: 34px; height: 34px; border-radius: 10px; background: #fff; display: grid; place-items: center; flex: none; overflow: hidden; }
.ppi-install-pill__logo img { width: 30px; height: 30px; object-fit: contain; }
.ppi-install-pill__text { display: grid; line-height: 1.2; }
.ppi-install-pill__text strong { font-size: 14px; font-weight: 700; }
.ppi-install-pill__text small { font-size: 11px; color: rgba(255, 255, 255, 0.68); letter-spacing: .02em; }
.ppi-install-pill__icon { color: var(--ppi-ui-gold); font-size: 15px; margin-left: 4px; }

/* a plain link-style trigger (footer list, mobile menu) */
.ppi-install-link { appearance: none; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-align: left; }

/* card for the member dashboard / admin dashboard */
.ppi-install-card {
    position: relative; overflow: hidden; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 14px; align-items: center;
    margin-top: 18px; padding: 16px; border-radius: 18px; font-family: var(--ppi-ui-font);
    background: radial-gradient(120% 140% at 100% 0%, #1d4ed8 0%, #0b1f4b 58%, #081a45 100%); color: #fff;
    box-shadow: 0 18px 40px -20px rgba(11, 31, 75, 0.85);
}
.ppi-install-card::after { content: ''; position: absolute; right: -34px; bottom: -34px; width: 120px; height: 120px; border-radius: 50%;
    border: 18px solid rgba(251, 191, 36, 0.12); pointer-events: none; }
.ppi-install-card__logo { width: 52px; height: 52px; border-radius: 14px; background: #fff; display: grid; place-items: center; }
.ppi-install-card__logo img { width: 44px; height: 44px; object-fit: contain; }
.ppi-install-card__text strong { display: block; font-size: 15px; font-weight: 700; line-height: 1.3; }
.ppi-install-card__text span { display: block; font-size: 12.5px; line-height: 1.45; color: rgba(255, 255, 255, 0.72); margin-top: 2px; }
.ppi-install-card__btn {
    grid-column: 1 / -1; appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 14px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 12px;
    color: #0b1f4b; background: linear-gradient(135deg, #fde68a, #fbbf24 55%, #f59e0b);
    box-shadow: 0 10px 22px -12px rgba(251, 191, 36, 0.9); position: relative; z-index: 1;
}
.ppi-install-card__btn:hover, .ppi-install-card__btn:focus-visible { filter: brightness(1.05); outline: 3px solid rgba(251, 191, 36, 0.35); outline-offset: 2px; }

/* the how-to sheet (opened when the browser cannot show its own install prompt) */
.ppi-sheet { position: fixed; inset: 0; z-index: 4100; display: flex; align-items: flex-end; justify-content: center; font-family: var(--ppi-ui-font); }
.ppi-sheet[hidden] { display: none; }
.ppi-sheet__backdrop { position: absolute; inset: 0; background: rgba(5, 12, 32, 0.62); backdrop-filter: blur(3px); animation: ppi-fade .25s ease both; }
.ppi-sheet__panel {
    position: relative; width: min(520px, 100%); max-height: calc(100vh - 24px); overflow: auto;
    background: #fff; color: #334155; border-radius: 24px 24px 0 0; padding: 22px 22px calc(22px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, 0.5); animation: ppi-sheet-up .34s cubic-bezier(.2, .9, .25, 1) both;
}
@media (min-width: 700px) {
    .ppi-sheet { align-items: center; padding: 24px; }
    .ppi-sheet__panel { border-radius: 24px; padding-bottom: 24px; }
}
.ppi-sheet__grab { width: 44px; height: 5px; border-radius: 3px; background: #e2e8f0; margin: -8px auto 16px; }
.ppi-sheet__head { display: grid; grid-template-columns: 56px minmax(0, 1fr) 34px; gap: 14px; align-items: center; margin-bottom: 16px; }
.ppi-sheet__logo { width: 56px; height: 56px; border-radius: 16px; background: #fff; border: 1px solid #e2e8f0; display: grid; place-items: center; box-shadow: 0 8px 20px -12px rgba(11, 31, 75, .5); }
.ppi-sheet__logo img { width: 46px; height: 46px; object-fit: contain; }
.ppi-sheet__title { font-size: 18px; font-weight: 800; color: #0f172a; line-height: 1.25; margin: 0; }
.ppi-sheet__sub { font-size: 13px; color: #64748b; margin: 2px 0 0; }
.ppi-sheet__close { appearance: none; border: 0; background: #f1f5f9; color: #334155; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.ppi-sheet__perks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.ppi-sheet__perks li { background: #f8fafc; border: 1px solid #eef2f7; border-radius: 12px; padding: 10px 8px; text-align: center; font-size: 12px; line-height: 1.35; color: #334155; }
.ppi-sheet__perks i { display: block; color: #2563eb; font-size: 17px; margin-bottom: 4px; }
.ppi-sheet__steps { list-style: none; margin: 0; padding: 0; counter-reset: s; display: grid; gap: 10px; }
.ppi-sheet__steps li { counter-increment: s; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; align-items: start; font-size: 14px; line-height: 1.5; color: #0f172a; }
.ppi-sheet__steps li::before { content: counter(s); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; background: linear-gradient(135deg, #2563eb, #0d9488); }
.ppi-sheet__steps b { font-weight: 700; }
.ppi-sheet__key { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 7px; background: #eef2ff; color: #1e3a8a; font-weight: 700; font-size: 13px; white-space: nowrap; }
.ppi-sheet__note { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: #fffbeb; color: #92400e; font-size: 12.5px; line-height: 1.5; }
.ppi-sheet__ok { margin-top: 18px; width: 100%; appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 15px; padding: 13px; border-radius: 14px; color: #fff; background: linear-gradient(135deg, #1d4ed8, #0b1f4b); }
@keyframes ppi-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ppi-sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- 3. app mode (installed) ---------------- */
.ppi-tabbar { display: none; }
html.is-app body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
@media (max-width: 900px) {
    /* the website only — the admin panel has no tab bar */
    html.is-app body:not(.admin-body) { --ppi-tabbar-h: 64px; }
    html.is-app body:not(.admin-body) .form-savebar { bottom: calc(16px + var(--ppi-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
    html.is-app body:not(.admin-body) .main-nav { padding-bottom: calc(28px + var(--ppi-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
    html.is-app .topbar { display: none !important; }
    html.is-app .site-header { padding-top: env(safe-area-inset-top, 0px); }
    html.is-app body:not(.admin-body) { padding-bottom: calc(var(--ppi-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
    html.is-app .scroll-top { bottom: calc(var(--ppi-tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)) !important; }
    html.is-app .ppi-tabbar {
        position: fixed; z-index: 900; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
        height: calc(var(--ppi-tabbar-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(255, 255, 255, 0.96); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
        border-top: 1px solid rgba(15, 23, 42, 0.08); box-shadow: 0 -10px 30px -18px rgba(11, 31, 75, 0.4); font-family: var(--ppi-ui-font);
    }
    .ppi-tabbar__item {
        appearance: none; border: 0; background: none; cursor: pointer; text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        color: #64748b; font-size: 10.5px; font-weight: 600; letter-spacing: .01em; position: relative; -webkit-user-select: none; user-select: none;
    }
    .ppi-tabbar__item i { font-size: 19px; line-height: 1; }
    .ppi-tabbar__item.is-active { color: #1d4ed8; }
    .ppi-tabbar__item.is-active::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: linear-gradient(90deg, #2563eb, #0d9488); }
    .ppi-tabbar__item--cta i { width: 42px; height: 42px; margin-top: -18px; border-radius: 50%; display: grid; place-items: center; font-size: 18px;
        color: #0b1f4b; background: linear-gradient(135deg, #fde68a, #fbbf24 55%, #f59e0b); box-shadow: 0 10px 22px -8px rgba(245, 158, 11, 0.8), 0 0 0 4px #fff; }
}
/* the admin panel in app mode: room for the notch */
html.is-app body.admin-body .admin-topbar { padding-top: env(safe-area-inset-top, 0px); }
html.is-app body.admin-body .admin-sidebar { padding-top: env(safe-area-inset-top, 0px); }

/* the admin sidebar's "Install App" is a <button>, styled like its links */
body.admin-body button.admin-nav__item { width: 100%; cursor: pointer; text-align: left; font-size: 14px; }
body.admin-body .admin-nav__item--install { margin-top: 10px; border: 1px dashed rgba(255, 255, 255, 0.16) !important; }
body.admin-body .admin-nav__item--install i { color: #fbbf24; }
