List.toggle('collapsed');
            });

            // View toggle
            gridViewBtn.addEventListener('click', () => {
                if (currentView !== 'grid') {
                    currentView = 'grid';
                    gridViewBtn.classList.add('active');
                    listViewBtn.classList.remove('active');
                    displayCurrentPage();

                    // Initialize lazy loading after switching views
                    setTimeout(() => initLazyLoading(), 50);

     