<!-- Footer -->
<footer class="wpbs-footer pt-5 pb-3" style="background-color: var(--wpbs-footer-bg);">
    <div class="container">
        <?php
        $columns = (int) get_theme_mod('wpbs_footer_columns', '3');
        $col_class = 'col-md-' . (12 / $columns);
        $has_widgets = false;
        
        for ($i = 1; $i <= $columns; $i++) {
            if (is_active_sidebar('footer-' . $i)) {
                $has_widgets = true;
                break;
            }
        }
        ?>
        
        <?php if ($has_widgets) : ?>
            <div class="row g-4 mb-4">
                <?php for ($i = 1; $i <= $columns; $i++) : ?>
                    <div class="<?php echo esc_attr($col_class); ?>">
                        <?php if (is_active_sidebar('footer-' . $i)) : ?>
                            <?php dynamic_sidebar('footer-' . $i); ?>
                        <?php endif; ?>
                    </div>
                <?php endfor; ?>
            </div>
        <?php endif; ?>

        <?php 
        // Footer menu
        if (has_nav_menu('footer')) : ?>
            <div class="row mb-3">
                <div class="col-12">
                    <?php wp_nav_menu([
                        'theme_location' => 'footer',
                        'container'      => false,
                        'menu_class'     => 'nav justify-content-center',
                        'link_before'    => '<span class="nav-link px-3 py-1">',
                        'link_after'     => '</span>',
                    ]); ?>
                </div>
            </div>
        <?php endif; ?>

        <!-- Copyright -->
        <div class="row wpbs-footer-bottom pt-3">
            <div class="col-12 text-center">
                <small class="text-muted"><?php echo wpbs_get_footer_text(); ?></small>
            </div>
        </div>
    </div>
</footer>

<?php wp_footer(); ?>
</body>
</html>
