/* ============================================================
   PWA UI: Splash Screen + زرار التثبيت + توست التحديث/الأوفلاين
   ملف منفصل عشان يبقى سهل نتحكم فيه من غير ما نلخبط style.css الرئيسي
   ============================================================ */

/* ---------- Splash Screen ----------
   بيظهر بس لما التطبيق يشتغل "متثبت" على الهاتف (standalone/fullscreen)،
   مش لزوار الموقع العاديين من المتصفح. مبني كـ overlay ثابت فوق الصفحة
   وبيختفي بـ fade بعد ما محتوى الصفحة يخلص تحميل. */
#pwaSplash {
    /* مخفي افتراضيًا (لزوار المتصفح العاديين). سطر <script> صغير في <head> بيضيف
       كلاس pwa-standalone على <html> بس لما التطبيق يكون شغال متثبت على الهاتف،
       فـ الـ splash يظهر بس في الحالة دي وقبل أي رسم للصفحة (مفيش وميض) */
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--primary, #FF6A1A);
    background: linear-gradient(160deg, var(--primary, #FF6A1A) 0%, var(--primary-dark, #E24E00) 100%);
    transition: opacity .45s ease, visibility .45s ease;
}
html.pwa-standalone #pwaSplash {
    display: flex;
    align-items: center;
    justify-content: center;
}
#pwaSplash.pwa-splash-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
#pwaSplash .pwa-splash-logo {
    width: 96px;
    height: 96px;
    border-radius: 26px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 34px -10px rgba(0, 0, 0, .35);
    animation: pwaSplashPop .6s cubic-bezier(.34, 1.56, .64, 1);
    overflow: hidden;
}
#pwaSplash .pwa-splash-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
#pwaSplash .pwa-splash-name {
    color: #fff;
    font-family: Tahoma, Arial, sans-serif;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: .3px;
}
#pwaSplash .pwa-splash-dots {
    display: flex;
    gap: 6px;
}
#pwaSplash .pwa-splash-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .85);
    animation: pwaSplashBlink 1.1s ease-in-out infinite;
}
#pwaSplash .pwa-splash-dots span:nth-child(2) { animation-delay: .15s; }
#pwaSplash .pwa-splash-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes pwaSplashPop {
    0% { transform: scale(.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes pwaSplashBlink {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- زرار "ثبّت التطبيق" العائم ---------- */
#pwaInstallBtn {
    position: fixed;
    inset-inline-start: 16px;
    bottom: 16px;
    z-index: 9500;
    display: none;
    align-items: center;
    gap: 8px;
    background: #201C16;
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 14px;
    font-family: inherit;
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .4);
    animation: pwaInstallIn .35s ease;
}
#pwaInstallBtn i { color: var(--primary, #FF6A1A); font-size: 16px; }
#pwaInstallBtn.pwa-visible { display: inline-flex; }
#pwaInstallBtn .pwa-install-close {
    margin-inline-start: 4px;
    opacity: .6;
    padding: 2px 4px;
}
#pwaInstallBtn .pwa-install-close:hover { opacity: 1; }

@keyframes pwaInstallIn {
    from { transform: translateY(14px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---------- توست عام (تحديث جديد / تم الحفظ أوفلاين) ---------- */
.pwa-toast {
    position: fixed;
    inset-inline: 16px;
    bottom: 16px;
    z-index: 9999;
    max-width: 420px;
    margin-inline: auto;
    background: #201C16;
    color: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13.5px;
    line-height: 1.6;
    box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .4);
    transform: translateY(120%);
    transition: transform .35s ease;
}
.pwa-toast.pwa-toast-show { transform: translateY(0); }
.pwa-toast i.pwa-toast-icon { color: var(--primary, #FF6A1A); font-size: 18px; flex-shrink: 0; }
.pwa-toast .pwa-toast-msg { flex: 1; }
.pwa-toast button.pwa-toast-action {
    background: var(--primary, #FF6A1A);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 9px;
    font-family: inherit;
    font-weight: 700;
    font-size: 12.5px;
    cursor: pointer;
    white-space: nowrap;
}
.pwa-toast button.pwa-toast-dismiss {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .6);
    cursor: pointer;
    padding: 4px;
    font-size: 15px;
    line-height: 1;
}
.pwa-toast button.pwa-toast-dismiss:hover { color: #fff; }

@media (max-width: 480px) {
    #pwaInstallBtn { inset-inline-start: 12px; bottom: 12px; padding: 11px 14px; font-size: 13px; }
    .pwa-toast { inset-inline: 12px; bottom: 12px; }
}
