/* اپ قابل‌نصب (PWA): دکمه‌ی نصب، راهنمای نصب (bottom sheet)، بنر، دکمه‌ی بازگشت iOS و safe-area حالت standalone.
   رنگ‌ها عمداً ثابت و مستقل از تم‌اند تا در سایت روشن، پنل کاربر تیره و پنل ادمین یکسان و خوانا باشند (کنتراست ≥ ۴٫۵). */

[data-pwa-install][hidden] { display: none !important; }

.pwa-install-btn--link,
.pwa-install-btn--nav {
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
    text-align: inherit;
    width: 100%;
}
.pwa-install-btn--link { width: auto; }

/* ── bottom sheet ── */
.pwa-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(15, 23, 42, .55);
    animation: pwa-fade .18s ease-out;
}
.pwa-sheet {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    color: #111827;
    border-radius: 22px 22px 0 0;
    padding: 12px 22px calc(22px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .25);
    font-family: inherit;
    animation: pwa-rise .22s ease-out;
}
.pwa-sheet-grip { width: 44px; height: 5px; border-radius: 99px; background: #d1d5db; margin: 0 auto 14px; }
.pwa-sheet-title { font-size: 1.05rem; font-weight: 800; margin: 0 0 12px; color: #111827; }
.pwa-sheet-steps { margin: 0 0 18px; padding: 0 20px 0 0; display: flex; flex-direction: column; gap: 10px; font-size: .92rem; line-height: 1.9; color: #374151; }
.pwa-sheet-steps svg { display: inline-block; vertical-align: middle; color: #2563eb; margin: 0 2px; }
.pwa-sheet-close {
    width: 100%; min-height: 46px; border: 0; border-radius: 14px; cursor: pointer;
    background: #1d4ed8; color: #fff; font: inherit; font-weight: 700;
}
.pwa-sheet-close:focus-visible,
.pwa-banner button:focus-visible,
.pwa-back-btn:focus-visible { outline: 3px solid #111827; outline-offset: 2px; }

/* ── بنر خودکار نصب (فقط موبایل) ── */
.pwa-banner {
    position: fixed;
    right: 12px;
    left: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #111827;
    color: #f9fafb;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    font-family: inherit;
}
.pwa-banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: .8rem; line-height: 1.6; }
.pwa-banner-text strong { font-size: .9rem; }
.pwa-banner-text span { color: #d1d5db; }
.pwa-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pwa-banner button { min-height: 40px; padding: 0 16px; border-radius: 12px; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: .85rem; }
.pwa-banner-install { background: #2563eb; color: #fff; }
.pwa-banner-later { background: transparent; color: #e5e7eb; border: 1px solid #4b5563 !important; }

/* ── دکمه‌ی بازگشت داخلی iOS (اپ نصب‌شده دکمه‌ی back مرورگر ندارد) ── */
.pwa-back-btn {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    right: 12px;
    z-index: 99980;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 0 14px 0 10px;
    border: 0;
    border-radius: 999px;
    background: rgba(17, 24, 39, .82);
    color: #fff;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* ── safe-area در حالت standalone (viewport-fit=cover): عناصر fixed پایین روی نوار خانه نیفتند ── */
html.pwa-standalone #cmp-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
html.pwa-standalone .ai-chat-widget { bottom: calc(28px + env(safe-area-inset-bottom)); }
html.pwa-standalone .cmp-toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
html.pwa-standalone body { overscroll-behavior-y: none; }

/* پیام ورود با گوگل در اپ نصب‌شده‌ی آیفون (صفحه‌ی ورود) */
.pwa-ios-login-note { display: none; margin: 10px 0 0; font-size: .8rem; line-height: 1.8; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 12px; }
html.pwa-standalone.pwa-ios .pwa-ios-login-note { display: block; }

@keyframes pwa-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pwa-rise { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .pwa-sheet-overlay, .pwa-sheet { animation: none; }
}
