/* إصلاح مشاكل التمرير على الموبايل - Sphinx Fire */

/* إعدادات عامة للتمرير على الموبايل */
@media (max-width: 768px) {
    /* التأكد من عمل التمرير الطبيعي */
    html {
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        overflow-x: hidden !important;
    }
    
    body {
        -webkit-overflow-scrolling: touch !important;
        overflow-x: hidden !important;
        overscroll-behavior-y: contain !important;
        overscroll-behavior-x: none !important;
    }
    
    /* منع تداخل touch events مع التمرير العادي */
    * {
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        -khtml-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
    }
    
    /* السماح بتحديد النصوص */
    p, span, h1, h2, h3, h4, h5, h6, input, textarea {
        -webkit-user-select: text !important;
        -khtml-user-select: text !important;
        -moz-user-select: text !important;
        -ms-user-select: text !important;
        user-select: text !important;
    }
    
    /* إصلاح مشاكل التمرير في الكاروسيل */
    .swiper, .swiper-container {
        touch-action: pan-x !important;
    }
    
    /* منع تداخل التمرير الأفقي مع العمودي */
    .hero-section, #hero {
        touch-action: pan-y !important;
    }
    
    /* التأكد من عمل التمرير في المحتوى */
    main, section, article, div {
        touch-action: pan-y !important;
    }
    
    /* إصلاح تداخل التمرير مع النوافذ المنبثقة */
    .modal, .popup, .dropdown {
        touch-action: pan-y !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* منع مشاكل التمرير في القوائم */
    .sticky-header nav.active {
        touch-action: pan-y !important;
        -webkit-overflow-scrolling: touch !important;
        overflow-y: auto !important;
        max-height: 60vh !important;
    }
    
    /* إصلاح مشاكل الـ sticky header */
    .sticky-header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 9999 !important;
        width: 100% !important;
        will-change: transform !important;
    }
    
    /* منع مشاكل الـ parallax على الموبايل */
    .parallax, .hero-slide.active .hero-video {
        transform: none !important;
    }
    
    /* إيقاف التأثيرات التي قد تتداخل مع التمرير */
    .animate-on-scroll, .scroll-reveal {
        transform: none !important;
        opacity: 1 !important;
    }
}

/* إصلاحات خاصة بـ iOS Safari */
@supports (-webkit-appearance: none) and (not (contain: paint)) {
    @media (max-width: 768px) {
        body {
            -webkit-overflow-scrolling: touch !important;
            position: relative !important;
            overflow-x: hidden !important;
        }
        
        /* منع مشاكل التمرير المزدوج في iOS */
        .ios-scroll-fix {
            -webkit-transform: translateZ(0) !important;
            transform: translateZ(0) !important;
        }
    }
}

/* إصلاحات خاصة بـ Android Chrome */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 1) {
    body {
        overflow-anchor: none !important;
    }
    
    /* منع مشاكل scroll snapping */
    html, body {
        scroll-snap-type: none !important;
    }
}

/* منع مشاكل التمرير مع الـ modals */
.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
}

/* إصلاح مشاكل التمرير مع القوائم المنسدلة */
.dropdown-open, .menu-open {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* CSS خاص بتحسين الأداء على الموبايل */
@media (max-width: 768px) {
    /* تحسين الأداء */
    * {
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
    }
    
    /* منع re-layout أثناء التمرير */
    .sticky-header, .fixed-element {
        will-change: transform !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
    }
    
    /* تحسين الـ animations على الموبايل */
    .advantage-card, .service-card, .project-card {
        animation-duration: 0.3s !important;
        transition-duration: 0.3s !important;
    }
}

/* Debug styles - يمكن إزالتها لاحقاً */
@media (max-width: 768px) {
    .scroll-debug {
        position: fixed;
        top: 100px;
        right: 10px;
        background: rgba(255, 0, 0, 0.8);
        color: white;
        padding: 5px;
        font-size: 12px;
        z-index: 10000;
        pointer-events: none;
    }
}
