<?php
/**
 * footer.php - فوتر مع تحميل غير متزامن
 */
?>
    <!-- Defer Bootstrap -->
    <script defer src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <!-- Optimized inline JS -->
    <script>
    // Lazy load images
    document.addEventListener('DOMContentLoaded',()=>{
        const images=document.querySelectorAll('img[data-src]');
        if('IntersectionObserver' in window){
            new IntersectionObserver(e=>e.forEach(e=>{
                if(e.isIntersecting){
                    const img=e.target;
                    img.src=img.dataset.src;
                    img.removeAttribute('data-src');
                }
            })).observe(images[0]);
        }
    });
    
    // Quick sidebar toggle
    const s=document.getElementById('sidebar'),o=document.getElementById('sidebarOverlay'),
          t=document.getElementById('menuToggle'),c=document.getElementById('sidebarClose');
    function open(){s?.classList.add('show');o?.classList.add('show');document.body.style.overflow='hidden'}
    function close(){s?.classList.remove('show');o?.classList.remove('show');document.body.style.overflow=''}
    t?.addEventListener('click',open);
    c?.addEventListener('click',close);
    o?.addEventListener('click',close);
    window.addEventListener('resize',()=>window.innerWidth>768&&close());
    </script>
</body>
</html>