function slide(containerId, direction) { const container = document.getElementById(containerId); const slides = container.querySelectorAll('.slide'); const currentScroll = container.scrollLeft; const slideWidth = slides[0].offsetWidth; const currentIndex = Math.round(currentScroll / slideWidth); const newIndex = direction === 'next' ? Math.min(currentIndex + 1, slides.length - 1) : Math.max(currentIndex - 1, 0); container.scrollTo({ left: newIndex * slideWidth, behavior: 'smooth' }); }