<?php
/**
 * The template for displaying the footer
 *
 * Contains the closing of the #content div and all content after.
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package ismoderna
 **/
?>
<style>
.w_footer {
    padding: 50px 0px 50px;
}

.widget-heading {
    padding: 30px 15px;
}

.widget-heading h1 {
    border-bottom: 2px solid #31A3DD;
    display: inline-block;
    font-size: 24px;
    padding: 5px 5px 5px 0;
    color: #fff;
}

#calendar_wrap {
    padding: 10px;
}

table.table, table {
    width: 100%;
    text-align: left;
    background-color: transparent;
}

#wp-calendar caption {
    padding: 10px;
    color: #fff;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    background-color: #f05036;
}

.footer-widget #wp-calendar thead tr th, .footer-widget table td {
    color: #101329;
}

#wp-calendar thead tr th, #wp-calendar tbody tr td {
    text-align: center;
    color: #101329;
}

table th, table td {
    border: 1px solid #dddddd;
    padding: 6px;
    line-height: 20px;
    text-align: center;
    vertical-align: top;
}

.footer-widget ul {
    list-style: none;
    padding-left: 20px;
    margin: 0;
}

.footer-widget ul li {
    display: block;
}

.footer-widget ul li a {
    font-size: 16px;
}

.wp-block-latest-posts.wp-block-latest-posts__list {
    list-style: none;
}
</style>

<!-- Start Footer Section -->
<?php
$ismoderna_footer_section_areas = get_theme_mod('ismoderna_footer_section_areas', '1');
if ($ismoderna_footer_section_areas == '1') { ?>
    <footer class="home-footer-bg">
        <?php if (is_active_sidebar('footer-widget-area-1') || is_active_sidebar('footer-widget-area-2') || is_active_sidebar('footer-widget-area-3') || is_active_sidebar('footer-widget-area-4')) : ?>
            <div class="container w_footer">
                <div class="row">
                    <?php
                    // Define widget areas and their fallback widgets
                    $footer_widget_areas = array(
                        'footer-widget-area-1' => array(
                            'widget' => 'WP_Widget_Calendar',
                            'title'  => __('Calendar', 'ismoderna'),
                        ),
                        'footer-widget-area-2' => array(
                            'widget' => 'WP_Widget_Pages',
                        ),
                        'footer-widget-area-3' => array(
                            'widget' => 'WP_Widget_Recent_Posts',
                        ),
                        'footer-widget-area-4' => array(
                            'widget' => 'WP_Widget_Archives',
                        ),
                    );

                    // Loop through widget areas and display content
                    foreach ($footer_widget_areas as $widget_area => $widget_data) :
                        echo '<div class="col-lg-3 col-md-4">';
                        if (is_active_sidebar($widget_area)) :
                            // Display sidebar content if available
                            dynamic_sidebar($widget_area);
                        else :
                            // Display fallback widget if no sidebar content is available
                            the_widget($widget_data['widget'], $widget_data);
                        endif;
                        echo '</div>';
                    endforeach;
                    ?>
                </div>
            </div>
       <?php endif; ?>
  </footer>
<?php } ?>
        <!-- Copy-right -->
        <div class="container">
            <div class="row justify-content-center">
                <div class="container-fluid">
                    <div class="copy-right">
                        <span class="copy-right-seprater"></span>
                        <p><?php echo esc_html_e("Proudly powered by", 'ismoderna'); ?> <a href="<?php echo esc_url("https://wordpress.org/") ?>" target="_blank"><?php echo esc_html_e("WordPress.", 'ismoderna'); ?></a>
                        <?php echo esc_html_e("Theme by", 'ismoderna'); ?><a href="<?php echo esc_url("https://infigosoftware.in/") ?>" target="_blank"> <?php echo esc_html_e("Infigo Software.", 'ismoderna'); ?></a></p>
                    </div>
                </div>
            </div>
        </div>
    

<!-- End Footer Section -->

</div> <!-- #page -->

<?php if (get_theme_mod('ismoderna_enable_scroll', '1') == 1) { ?>
    <a href="#" id="btn-to-top" class="show"><i class="fas fa-arrow-up"></i></a>
<?php } ?>

<?php wp_footer(); ?>

</body>
</html>
