/* ============================================================
   PWA.CSS – استایل‌های اختصاصی PWA
   نسخه: 4.0
   
   ⚠️ توجه: منوی موبایل و همبرگر در header.php تعریف شده‌اند.
       این فایل فقط استایل‌های PWA را دارد.
   ============================================================ */

/* ============================================================
   ۱. Safe Areas برای اپ نصب‌شده (iOS)
   ============================================================ */
:root {
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left, 0px);
    --safe-right:  env(safe-area-inset-right, 0px);
}

@media (display-mode: standalone) {
    /* ⚠️ padding-top روی body فقط برای safe-area */
    body {
        padding-top: var(--safe-top);
    }
    
    /* در حالت نصب‌شده، دکمه نصب را مخفی کن */
    .pwa-install-btn {
        display: none !important;
    }
}

@media (display-mode: fullscreen) {
    .pwa-install-btn {
        display: none !important;
    }
}

/* ============================================================
   ۲. دکمه نصب اپلیکیشن
   ============================================================ */
.pwa-install-btn {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    left: calc(24px + var(--safe-left));
    display: none;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #fcd34d, #e0a82e);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-family: inherit;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    box-shadow:
        0 12px 32px rgba(240,201,80,.45),
        inset 0 2px 0 rgba(255,255,255,.4);
    z-index: 9998;
    text-shadow: 0 1px 2px rgba(140,95,10,.3);
    transition: all .3s cubic-bezier(.2,.9,.3,1.2);
    animation: pwaSlideIn .5s ease, pwaPulse 3s ease-in-out infinite;
}

.pwa-install-btn.show {
    display: inline-flex;
}

.pwa-install-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow:
        0 18px 42px rgba(240,201,80,.55),
        inset 0 2px 0 rgba(255,255,255,.5);
}

.pwa-install-btn .pwa-icon {
    font-size: 1.2rem;
    animation: bounceIcon 2s infinite;
}

@keyframes pwaSlideIn {
    from { opacity: 0; transform: translateY(50px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pwaPulse {
    0%, 100% {
        box-shadow:
            0 12px 32px rgba(240,201,80,.45),
            inset 0 2px 0 rgba(255,255,255,.4);
    }
    50% {
        box-shadow:
            0 12px 42px rgba(240,201,80,.55),
            0 0 0 8px rgba(240,201,80,.15),
            inset 0 2px 0 rgba(255,255,255,.5);
    }
}

@keyframes bounceIcon {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

/* ============================================================
   ۳. پاپ‌آپ iOS
   ============================================================ */
.pwa-ios-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card, #fff);
    border-top: 4px solid var(--gold, #e0a82e);
    border-radius: 24px 24px 0 0;
    padding: 22px 24px calc(30px + var(--safe-bottom));
    box-shadow: 0 -20px 60px rgba(0,0,0,.2);
    z-index: 99999;
    transform: translateY(100%);
    transition: transform .4s cubic-bezier(.2,.9,.3,1.2);
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.pwa-ios-prompt.show { transform: translateY(0); }

html[data-theme="dark"] .pwa-ios-prompt {
    background: #131b2a;
    box-shadow: 0 -20px 60px rgba(0,0,0,.6);
}

.pwa-ios-prompt .pwa-ios-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #fcd34d, #e0a82e);
    color: #fff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    box-shadow: 0 10px 24px rgba(240,201,80,.45);
}

.pwa-ios-prompt .pwa-ios-body { flex: 1; min-width: 0; }

.pwa-ios-prompt h4 {
    margin: 0 0 8px;
    color: var(--text, #0f172a);
    font-size: 1rem;
    font-weight: 800;
}

.pwa-ios-prompt p {
    margin: 0 0 8px;
    color: var(--text-soft, #475569);
    font-size: .88rem;
    line-height: 1.7;
}

.pwa-ios-prompt .pwa-ios-steps {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    color: var(--text-mute, #94a3b8);
    margin-bottom: 12px;
}

.pwa-ios-prompt .pwa-ios-steps .step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(224,168,46,.12);
    color: var(--gold, #e0a82e);
    border-radius: 8px;
    font-size: 1rem;
    flex-shrink: 0;
}

.pwa-ios-prompt .pwa-ios-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0,0,0,.06);
    border-radius: 50%;
    color: var(--text-mute, #94a3b8);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .25s;
    font-family: inherit;
    line-height: 1;
}

.pwa-ios-prompt .pwa-ios-close:hover {
    background: var(--gold, #e0a82e);
    color: #fff;
    transform: rotate(90deg);
}

html[data-theme="dark"] .pwa-ios-prompt .pwa-ios-close {
    background: rgba(255,255,255,.1);
}

/* ============================================================
   ۴. بنر آپدیت نسخه
   ============================================================ */
.pwa-update-banner {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    right: calc(24px + var(--safe-right));
    display: none;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e8eef5);
    border-right: 5px solid var(--gold, #e0a82e);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
    z-index: 99999;
    animation: pwaSlideIn .4s ease;
}

.pwa-update-banner.show { display: flex; }

html[data-theme="dark"] .pwa-update-banner {
    background: #131b2a;
    border-color: #1e2a3d;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

.pwa-update-banner .update-icon {
    font-size: 1.5rem;
    color: var(--gold, #e0a82e);
    animation: spin 2s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.pwa-update-banner .update-text {
    color: var(--text, #0f172a);
    font-size: .9rem;
    font-weight: 700;
    margin: 0;
}

.pwa-update-banner .update-btn {
    padding: 8px 18px;
    background: linear-gradient(135deg, #fcd34d, #e0a82e);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-family: inherit;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    transition: all .25s;
    text-shadow: 0 1px 2px rgba(140,95,10,.3);
}

.pwa-update-banner .update-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(240,201,80,.45);
}

/* ============================================================
   ۵. نوار وضعیت آنلاین/آفلاین
   ============================================================ */
.pwa-offline-badge {
    position: fixed;
    top: calc(12px + var(--safe-top));
    right: 50%;
    transform: translate(50%, -100px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: #fff;
    border-radius: 30px;
    font-size: .85rem;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(220,53,69,.4);
    z-index: 99999;
    transition: transform .4s cubic-bezier(.2,.9,.3,1.2);
    pointer-events: none;
}

.pwa-offline-badge.show { transform: translate(50%, 0); }

.pwa-offline-badge .dot {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: pulseDot 2s infinite;
}

.pwa-offline-badge.online {
    background: linear-gradient(135deg, #28a745, #20c997);
    box-shadow: 0 8px 24px rgba(40,167,69,.4);
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .4; transform: scale(1.3); }
}

/* ============================================================
   ۶. ریسپانسیو
   ============================================================ */
@media (max-width: 500px) {
    .pwa-install-btn {
        bottom: calc(16px + var(--safe-bottom));
        left: calc(16px + var(--safe-left));
        right: calc(16px + var(--safe-right));
        justify-content: center;
        padding: 13px 20px;
    }

    .pwa-ios-prompt { padding: 20px 20px 26px; }
    .pwa-ios-prompt h4 { font-size: .95rem; }
    .pwa-ios-prompt p { font-size: .82rem; }

    .pwa-update-banner {
        left: 16px;
        right: 16px;
        bottom: calc(16px + var(--safe-bottom));
        flex-direction: column;
        text-align: center;
    }

    .pwa-offline-badge {
        top: calc(8px + var(--safe-top));
        font-size: .8rem;
        padding: 6px 16px;
    }
}

/* ============================================================
   ۷. کاهش حرکت
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .pwa-install-btn,
    .pwa-ios-prompt,
    .pwa-update-banner {
        animation: none !important;
        transition-duration: .01ms !important;
    }

    .pwa-install-btn .pwa-icon,
    .pwa-update-banner .update-icon,
    .pwa-offline-badge .dot {
        animation: none !important;
    }
}