<?php

$footer_nav = ethrik_get_option('footer_nav');
$footer_copyright_text = ethrik_get_option('copyright_text');
$footer_copyright_text_allowed_tags = array(
    'a' => array(
        'href' => array(),
        'title' => array()
    ),
    'img' => array(
        'alt' => array(),
        'src' => array()
    ),
    'br' => array(),
    'em' => array(),
    'strong' => array(),
);

$ethrik_logo = ethrik_get_option('theme_logo');
$ethrik_logo_id = isset($ethrik_logo['id']) && !empty($ethrik_logo['id']) ? $ethrik_logo['id'] : '';
$ethrik_logo_url = isset($ethrik_logo['url']) ? $ethrik_logo['url'] : '';
$ethrik_logo_alt = get_post_meta($ethrik_logo_id, '_wp_attachment_image_alt', true);

?>

<style>
    .footer-top-subscribe-area {
        padding-top: 60px;
        padding-bottom: 30px;
        border-bottom: 0.7px solid #222;
    }

    .footer-style-two .logo .text-logo {
        font-size: 50px;
        line-height: 1;
    }

    .footer-style-two .logo .text-logo a {
        display: inline-block;
        line-height: 1;
    }

    .footer-style-two .subscribe-area h2 {
        margin: 30px 0;
        font-weight: 300;
    }

    .footer-style-two .subscribe-form {
        width: 50%;
        margin: 0 auto;
    }

    .footer-style-two .footer-social {
        margin-top: 0;
    }

    .footer-style-two .footer-top {
        padding-top: 50px !important;
        padding-bottom: 30px !important;
    }

    /* RESPONSIVE CSS */
    @media (max-width: 767px) {
        .footer-style-two .subscribe-form {
            width: 100%;
        }
    }

    @media (max-width: 575px) {
        .footer-top .col-lg-3.col-md-6.col-sm-6 {
            margin-bottom: 30px;
        }

        .footer-top .col-lg-3.col-md-6.col-sm-6:last-child {
            margin-bottom: 0;
        }
    }

    @media (max-width: 450px) {
        .footer-style-two .subscribe-area h2 {
            font-size: 22px;
            margin: 15px 0;
        }

        .footer-email {
            height: 45px;
            border-radius: 5px;
        }

        .footer-submit {
            padding: 9px 10px;
            font-size: 16px;
            border-radius: 5px;
        }
    }

    @media (max-width: 340px) {
        .footer-style-two .subscribe-area h2 {
            font-size: 18px;
            margin: 5px 0;
        }

        .footer-email::placeholder {
            font-size: 13px;
        }

        .footer-submit {
            padding: 11px 10px;
            font-size: 13px;
        }

        .wp-block-latest-posts a {
            font-size: 14px !important;
        }

        .footer-widget ul li,
        .wp-block-categories .cat-item,
        .wp-block-latest-posts,
        .footer-widget h4.widget-title,
        .footer-widget.widget_block h3,
        .wp-block-heading {
            margin-bottom: 10px;
        }

        .footer-widget ul li a,
        .wp-block-categories .cat-item a {
            font-size: 14px;
        }
    }
</style>

<!-- footer area start -->
<footer class="theme-footer-wrapper footer-style-two theme_footer_Widegts 
    <?php if (is_active_sidebar('footer-widget-1')) {
        echo "hav-footer-topp";
    } else {
        echo "no-footer-top";
    }
    ?>">

    <div class="footer-top-subscribe-area">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="logo theme-logo text-center">
                        <?php
                        if (has_custom_logo() || !empty($ethrik_logo_url)) {
                            if (isset($ethrik_logo['url']) && !empty($ethrik_logo_url)) {
                        ?>
                                <a href="<?php echo esc_url(site_url('/')) ?>" class="logo">
                                    <img class="img-fluid" src="<?php echo esc_url($ethrik_logo_url); ?>" alt="<?php echo esc_attr($ethrik_logo_alt) ?>">
                                </a>
                        <?php
                            } else {
                                the_custom_logo();
                            }
                        } else {
                            printf('<h1 class="text-logo"><a href="%1$s">%2$s</a></h1>', esc_url(site_url('/')), esc_html(get_bloginfo('name')));
                        }
                        ?>
                    </div>
                    <div class="subscribe-area text-center">
                        <h2>Get the latest Ethrik updates</h2>
                        <div class="subscribe-form">
                            <?php dynamic_sidebar('footer-subscribe-form'); ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php if (is_active_sidebar('footer-widget-1')) : ?>
        <div class="footer-top">
            <div class="container">
                <div class="row justify-content-between">

                    <?php if (is_active_sidebar('footer-widget-5')): ?>
                        <div class="col-lg-3 col-md-6 col-sm-6">
                            <?php dynamic_sidebar('footer-widget-5'); ?>
                        </div>
                    <?php endif; ?>

                    <?php if (is_active_sidebar('footer-widget-2')): ?>
                        <div class="col-lg-3 col-md-6 col-sm-6">
                            <?php dynamic_sidebar('footer-widget-2'); ?>
                        </div>
                    <?php endif; ?>

                    <?php if (is_active_sidebar('footer-widget-3')): ?>
                        <div class="col-lg-3 col-md-6 col-sm-6">
                            <?php dynamic_sidebar('footer-widget-3'); ?>
                        </div>
                    <?php endif; ?>

                    <?php if (is_active_sidebar('footer-widget-6')): ?>
                        <div class="col-lg-3 col-md-6 col-sm-6">
                            <?php dynamic_sidebar('footer-widget-6'); ?>
                        </div>
                    <?php endif; ?>

                </div>
            </div>
        </div>
    <?php endif; ?>
    <div class="footer-bottom">
        <div class="container">
            <div class="row align-items-center">

                <div class="col-lg-6 text-left">
                    <p class="copyright-text">
                        <?php
                        if (!empty($footer_copyright_text)) {
                            echo wp_kses($footer_copyright_text, $footer_copyright_text_allowed_tags);
                        } else {
                            printf(
                                esc_html__('Copyright &copy; Ethrik %s. All rights reserved', 'ethrik'),
                                date('Y')
                            );
                        }
                        ?>
                    </p>
                </div>

                <?php if ($footer_nav == true) : ?>
                    <div class="col-lg-6 text-right">
                        <div class="footer-social">
                            <a href="#"><i class="fab fa-telegram"></i></a>
                            <a href="#"><i class="fab fa-twitter"></i></a>
                            <a href="#"><i class="fab fa-youtube"></i></a>
                            <a href="#"><i class="fab fa-discord"></i></a>
                            <a href="#"><i class="fab fa-instagram"></i></a>
                        </div>
                    </div>
                <?php endif; ?>

            </div>
        </div>
    </div>
</footer>
<!-- footer area end -->