/**
 * PWA Styles - متجر تصاميم النقشات
 * Professional PWA UI Components
 */

/* ==================== Install Banner ==================== */
.pwa-install-banner {
    position: fixed;
    bottom: -200px;
    left: 1rem;
    right: 1rem;
    background: linear-gradient(135deg, #7C3AED, #5B21B6);
    color: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(124, 58, 237, 0.4);
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 500px;
    margin: 0 auto;
}

.pwa-install-banner.visible {
    bottom: 1rem;
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
}

.pwa-install-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.pwa-install-text {
    flex: 1;
}

.pwa-install-text h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.pwa-install-text p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0;
}

.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pwa-install-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    color: #7C3AED;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.pwa-install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.pwa-close-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.pwa-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==================== Update Prompt ==================== */
.pwa-update-prompt {
    position: fixed;
    top: -200px;
    left: 1rem;
    right: 1rem;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(16, 185, 129, 0.4);
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 500px;
    margin: 0 auto;
}

.pwa-update-prompt.visible {
    top: 1rem;
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
}

.pwa-update-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.pwa-update-text {
    flex: 1;
}

.pwa-update-text h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.pwa-update-text p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0;
}

.pwa-update-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    color: #10B981;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.pwa-update-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* ==================== Offline Indicator ==================== */
.offline-mode .offline-indicator {
    display: flex !important;
}

.offline-indicator {
    display: none;
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #EF4444, #DC2626);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
    z-index: 9998;
    font-size: 0.875rem;
    font-weight: 600;
    align-items: center;
    gap: 0.5rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.offline-indicator-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ==================== Offline Mode Styles ==================== */
.offline-mode .requires-online {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.offline-mode .requires-online::after {
    content: 'يتطلب اتصال بالإنترنت';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 10;
}

.offline-mode .requires-online:hover::after {
    opacity: 1;
}

/* ==================== PWA Installed Badge ==================== */
.pwa-installed .pwa-badge {
    display: inline-flex !important;
}

.pwa-badge {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 600;
}

.pwa-badge-icon {
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

/* ==================== Loading States ==================== */
.pwa-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.pwa-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(124, 58, 237, 0.3);
    border-top-color: #7C3AED;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== Splash Screen (iOS) ==================== */
.pwa-splash {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #7C3AED, #5B21B6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: fadeOut 0.5s ease-out 2s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        pointer-events: none;
    }
}

.pwa-splash-logo {
    width: 120px;
    height: 120px;
    background: white;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    margin-bottom: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: pulse 1.5s ease-in-out infinite;
}

.pwa-splash-text {
    color: white;
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {

    .pwa-install-banner,
    .pwa-update-prompt {
        left: 0.5rem;
        right: 0.5rem;
    }

    .pwa-install-content,
    .pwa-update-content {
        padding: 1rem;
        gap: 0.75rem;
    }

    .pwa-install-icon,
    .pwa-update-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .pwa-install-text h4,
    .pwa-update-text h4 {
        font-size: 0.9375rem;
    }

    .pwa-install-text p,
    .pwa-update-text p {
        font-size: 0.8125rem;
    }

    .pwa-install-btn,
    .pwa-update-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }

    .offline-indicator {
        top: 70px;
        font-size: 0.8125rem;
        padding: 0.625rem 1.25rem;
    }
}

@media (max-width: 480px) {

    .pwa-install-content,
    .pwa-update-content {
        flex-wrap: wrap;
    }

    .pwa-install-actions,
    .pwa-update-btn {
        width: 100%;
        justify-content: center;
    }

    .pwa-install-btn {
        flex: 1;
    }
}

/* ==================== Print Styles ==================== */
@media print {

    .pwa-install-banner,
    .pwa-update-prompt,
    .offline-indicator,
    .pwa-badge {
        display: none !important;
    }
}

/* ==================== Accessibility ==================== */
.pwa-install-btn:focus,
.pwa-update-btn:focus,
.pwa-close-btn:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* ==================== Dark Mode Support ==================== */
@media (prefers-color-scheme: dark) {

    .pwa-install-banner,
    .pwa-update-prompt {
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    }
}

/* ==================== Reduced Motion ==================== */
@media (prefers-reduced-motion: reduce) {

    .pwa-install-banner,
    .pwa-update-prompt,
    .offline-indicator,
    .pwa-update-icon,
    .pwa-splash-logo {
        animation: none !important;
        transition: none !important;
    }
}