﻿/* ==========================================
   PWA Styles - اضافه کن به انتهای site.css
   ========================================== */

/* دکمه نصب PWA */
.pwa-install-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    z-index: 9998;
    transition: all 0.3s;
    animation: pulse 2s infinite;
    display: none;
}

    .pwa-install-button:hover {
        transform: translateY(-3px);
        box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
    }

    .pwa-install-button i {
        margin-left: 8px;
    }

@@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    }

    50% {
        box-shadow: 0 4px 30px rgba(102, 126, 234, 0.8);
    }
}

/* نوتیفیکیشن آپدیت */
.pwa-update-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    left: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    animation: slideDown 0.3s ease-out;
}

.pwa-update-content {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

    .pwa-update-content i {
        font-size: 1.5rem;
        color: #667eea;
    }

    .pwa-update-content span {
        flex: 1;
        min-width: 150px;
        font-weight: bold;
        color: #2d3748;
    }

    .pwa-update-content button {
        margin: 5px;
    }

@@keyframes slideDown {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* نوار وضعیت آنلاین/آفلاین */
.pwa-status-bar {
    display:none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    text-align: center;
    font-weight: bold;
    z-index: 9997;
    animation: slideDown 0.3s ease-out;
}

    .pwa-status-bar.online {
        background: linear-gradient(135deg, #48bb78, #38a169);
        color: white;
    }

    .pwa-status-bar.offline {
        background: linear-gradient(135deg, #f56565, #e53e3e);
        color: white;
    }

    .pwa-status-bar i {
        margin-left: 8px;
    }

/* حالت Standalone (وقتی به عنوان اپ نصب شده) */
@@media all and (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .pwa-install-button {
        display: none !important;
    }
    /* افزودن نوار بالایی برای iOS */
    .top-bar {
        padding-top: calc(15px + env(safe-area-inset-top));
    }
    /* نمایش Badge اپ */
    .app-badge {
        display: inline-flex !important;
        align-items: center;
        gap: 8px;
        padding: 5px 12px;
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
        border-radius: 20px;
        font-size: 0.75rem;
        color: #667eea;
        font-weight: bold;
        margin-right: 10px;
    }
}

.app-badge {
    display: none;
}

/* Loading Spinner برای همگام‌سازی */
.sync-spinner {
    position: fixed;
    bottom: 80px;
    left: 20px;
    background: white;
    padding: 15px;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    animation: spin 1s linear infinite;
}

    .sync-spinner i {
        color: #667eea;
        font-size: 1.2rem;
    }

@@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Badge برای تعداد آیتم‌های آفلاین */
.offline-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #f56565;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 1;
    transition: opacity 0.5s;
}

    .splash-screen.hide {
        opacity: 0;
        pointer-events: none;
    }

    .splash-screen img {
        width: 120px;
        height: 120px;
        margin-bottom: 30px;
        animation: bounce 1s infinite;
    }

    .splash-screen h1 {
        color: white;
        font-size: 1.8rem;
        margin-bottom: 10px;
    }

    .splash-screen p {
        color: rgba(255, 255, 255, 0.8);
    }

@@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* صفحه آفلاین */
.offline-content {
    text-align: center;
    padding: 60px 20px;
}

    .offline-content i {
        font-size: 5rem;
        color: #cbd5e0;
        margin-bottom: 20px;
    }

    .offline-content h2 {
        color: #2d3748;
        margin-bottom: 15px;
    }

    .offline-content p {
        color: #718096;
        margin-bottom: 30px;
    }

/* Responsive برای موبایل */
@@media (max-width: 768px) {
    .pwa-install-button {
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 40px);
        max-width: 300px;
    }

    .pwa-update-notification {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .pwa-update-content {
        flex-direction: column;
        text-align: center;
    }

        .pwa-update-content button {
            width: 100%;
        }

    .sync-spinner {
        bottom: 90px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* حالت Dark Mode (اختیاری) */
@@media (prefers-color-scheme: dark) {
    .pwa-update-notification {
        background: #2d3748;
    }

    .pwa-update-content span {
        color: white;
    }

    .sync-spinner {
        background: #2d3748;
    }

    .offline-content h2 {
        color: white;
    }

    .offline-content p {
        color: #cbd5e0;
    }
}

/* iOS Safe Area */
@@supports (padding: max(0px)) {
    .main-content {
        padding-right: max(30px, env(safe-area-inset-right));
        padding-left: max(30px, env(safe-area-inset-left));
        padding-bottom: max(30px, env(safe-area-inset-bottom));
    }

    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Print - پنهان کردن المان‌های PWA هنگام چاپ */
@@media print {
    .pwa-install-button,
    .pwa-update-notification,
    .pwa-status-bar,
    .sync-spinner,
    .app-badge {
        display: none !important;
    }
}
