<?php if (! defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}
$cols = get_theme_mod('welding_for_elementor_footer_columns', '4');
if ($cols == '1') {
    $col_class = 'col-xl-12 col-lg-12 col-md-12 col-12';
} elseif ($cols == '2') {
    $col_class = 'col-xl-6 col-lg-6 col-md-6 col-12';
} elseif ($cols == '3') {
    $col_class = 'col-xl-4 col-lg-4 col-md-6 col-12';
} else {
    $col_class = 'col-xl-3 col-lg-3 col-md-6 col-12';
}

$copyright_switch = get_theme_mod('welding_for_elementor_copyright_switch', 'on');
$copyright_text = get_theme_mod('welding_for_elementor_copyright_text', esc_html__('© 2026 Welding for Elementor. All rights reserved.', 'welding-for-elementor'));
$facebook_url = get_theme_mod('welding_for_elementor_facebook_url', '#');
$twitter_url = get_theme_mod('welding_for_elementor_twitter_url', '#');
$instagram_url = get_theme_mod('welding_for_elementor_instagram_url', '#');
$linkedin_url  = get_theme_mod('welding_for_elementor_linkedin_url', '#');
$youtube_url   = get_theme_mod('welding_for_elementor_youtube_url', '#');
$pinterest_url = get_theme_mod('welding_for_elementor_pinterest_url', '#');
$whatsapp_url  = get_theme_mod('welding_for_elementor_whatsapp_url', '#');
$snapchat_url  = get_theme_mod('welding_for_elementor_snapchat_url', '#');
?>
<!-- footer area start -->
<footer class="tr-footer p-relative">
    <div class="container">
        <?php if (is_active_sidebar('footer-widget-1') || is_active_sidebar('footer-widget-2') || is_active_sidebar('footer-widget-3') || is_active_sidebar('footer-widget-4')) : ?>
            <div class="tr-footer-widget-border pt-90">
                <div class="row">
                    <!-- FOOTER WIDGET STYLE FOR 3 COLUMNS ON WELDING FOR ELEMENTOR THEME -->
                    <?php if ($cols == '3') : ?>
                        <div class="col-xl-4 col-lg-4 col-md-6 col-12">
                            <?php dynamic_sidebar("footer-widget-1") ?>
                        </div>
                        <div class="col-xl-2 col-lg-2 col-md-6 col-12">
                        </div>
                        <div class="col-xl-3 col-lg-3 col-md-6 col-12">
                            <?php dynamic_sidebar("footer-widget-2") ?>
                        </div>
                        <div class="col-xl-3 col-lg-3 col-md-6 col-12">
                            <?php dynamic_sidebar("footer-widget-3") ?>
                        </div>
                    <?php else : ?>
                        <?php for ($i = 1; $i <= $cols; $i++) { ?>
                            <div class="<?php echo $col_class; ?>">
                                <?php dynamic_sidebar("footer-widget-$i") ?>
                            </div>
                        <?php } ?>
                    <?php endif; ?>

                </div> <!-- row -->
            </div> <!-- tr-footer-widget-border -->
        <?php endif; ?>
    </div> <!-- container -->
    <?php if ($copyright_switch) : ?>
        <div class="tr-footer-copyright border-top border-dark pt-32 pb-32">
            <div class="container">
                <div class="d-flex flex-wrap align-items-center justify-content-between gap-3">
                    <p class="tr-footer-copyright-text">
                        <?php echo esc_html($copyright_text); ?>
                    </p>
                    <div class="tr-copyright-social d-flex align-items-center gap-3">
                        <?php if (!empty($facebook_url)) : ?>
                            <a href="<?php echo esc_url($facebook_url); ?>" target="_blank" rel="noopener noreferrer"><i class="fa fa-facebook" aria-hidden="true"></i></a>
                        <?php endif; ?>
                        <?php if (!empty($twitter_url)) : ?>
                            <a href="<?php echo esc_url($twitter_url); ?>" target="_blank" rel="noopener noreferrer"><i class="fa fa-twitter" aria-hidden="true"></i></a>
                        <?php endif; ?>
                        <?php if (!empty($instagram_url)) : ?>
                            <a href="<?php echo esc_url($instagram_url); ?>" target="_blank" rel="noopener noreferrer">
                                <i class="fa fa-instagram" aria-hidden="true"></i>
                            </a>
                        <?php endif; ?>
                        <?php if (!empty($linkedin_url)) : ?>
                            <a href="<?php echo esc_url($linkedin_url); ?>" target="_blank" rel="noopener noreferrer">
                                <i class="fa fa-linkedin" aria-hidden="true"></i>
                            </a>
                        <?php endif; ?>

                        <?php if (!empty($youtube_url)) : ?>
                            <a href="<?php echo esc_url($youtube_url); ?>" target="_blank" rel="noopener noreferrer">
                                <i class="fa fa-youtube" aria-hidden="true"></i>
                            </a>
                        <?php endif; ?>

                        <?php if (!empty($pinterest_url)) : ?>
                            <a href="<?php echo esc_url($pinterest_url); ?>" target="_blank" rel="noopener noreferrer">
                                <i class="fa fa-pinterest" aria-hidden="true"></i>
                            </a>
                        <?php endif; ?>

                        <?php if (!empty($whatsapp_url)) : ?>
                            <a href="<?php echo esc_url($whatsapp_url); ?>" target="_blank" rel="noopener noreferrer">
                                <i class="fa fa-whatsapp" aria-hidden="true"></i>
                            </a>
                        <?php endif; ?>

                        <?php if (!empty($snapchat_url)) : ?>
                            <a href="<?php echo esc_url($snapchat_url); ?>" target="_blank" rel="noopener noreferrer">
                                <i class="fa fa-snapchat-ghost" aria-hidden="true"></i>
                            </a>
                        <?php endif; ?>
                    </div> <!-- tr-copyright-social -->
                </div> <!-- d-flex -->
            </div> <!-- container -->
        </div> <!-- tr-footer-copyright -->
    <?php endif; ?>
</footer>
<!-- footer area end -->