function toggleRecent() {
    const isActive = document.getElementById('recentBtn').classList.contains('active');
    document.getElementById('recentBtn').classList.toggle('active', !isActive);
    document.getElementById('favBtn').classList.remove('active');
    viewMode = isActive ? 'all' : 'recent';
    renderGrid();
}

function toggleFavView() {
    const isActive = document.getElementById('favBtn').classList.contains('active');
    document.getElementById('favBtn').classList.toggle('active', !isActive);
    document.getElementById('recentBtn').classList.remove('active');
    viewMode = isActive ? 'all' : 'favorite';
    renderGrid();
}

function onSearchInput() {
    searchQuery = document.getElementById('searchInput').value.toLowerCase().trim();
    renderGrid();
}
