<?php
// This file assumes $pdo and $t are available from the calling page.
if (!isset($sliders)) {
    $sliders = get_all_sliders($pdo);
}
?>
<?php if (!empty($sliders)): ?>
<section class="slider-section">
    <div class="container">
        <div class="slider-wrapper">
            <div class="slider-container">
                <?php foreach ($sliders as $index => $slide): ?>
                    <div class="slider-item <?php echo $index === 0 ? 'active' : ''; ?>">
                        <a href="<?php echo htmlspecialchars($slide['link_url'] ?? '#'); ?>" class="slider-link">
                            <div class="slider-content">
                                <img src="<?php echo htmlspecialchars($slide['image_url']); ?>" class="slider-image" alt="<?php echo htmlspecialchars($slide['title']); ?>">
                                <div class="slider-overlay">
                                    <div class="slider-text">
                                        <h2 class="slider-title"><?php echo htmlspecialchars($slide['title']); ?></h2>
                                        <p class="slider-description"><?php echo htmlspecialchars($slide['description']); ?></p>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </div>
                <?php endforeach; ?>
            </div>
            <?php if (count($sliders) > 1): ?>
                <button class="slider-control slider-prev" aria-label="Previous slide">‹</button>
                <button class="slider-control slider-next" aria-label="Next slide">›</button>
            <?php endif; ?>
        </div>
    </div>
</section>
<?php endif; ?>