<?php if (authCheck()): ?>
<?= loadCommonView('post/_add_post_modal'); ?>
<?php endif; ?>

<?= loadCommonView("partials/_newsletter_popup"); ?>

<footer id="footer">
<div class="footer-inner">
<div class="container-xl">
<div class="row justify-content-between">
<div class="col-sm-12 col-md-6 col-lg-4 footer-widget footer-widget-about">
<div class="footer-logo">
<img src="<?= getLogo('dark'); ?>" alt="logo" class="logo" width="<?= getLogoSize()->width; ?>" height="<?= getLogoSize()->height; ?>">
</div>
<div class="footer-about">
<?= esc($baseSettings->about_footer); ?>
</div>
<div class="footer-social-links">
<?= view('themes/common/partials/_social_media_links', ['rssHide' => false]); ?>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4 footer-widget">
<h4 class="widget-title"><?= trans("trending_posts"); ?></h4>
<div class="footer-posts">
<?= view_cell('App\Cells\TrendingPosts', ['latestCategoryPosts' => $latestCategoryPosts]); ?>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4 footer-widget">
<?php if ((int)$config->newsletter_settings->status === 1): ?>
<h4 class="widget-title"><?= trans("newsletter"); ?></h4>
<div class="newsletter">
<p class="description"><?= trans("newsletter_join_desc"); ?></p>
<form id="form_newsletter_footer" class="form-newsletter">
<div class="newsletter-inputs">
<input type="email" name="email" class="form-control form-input newsletter-input" maxlength="199" placeholder="<?= trans("email"); ?>">
<button type="submit" name="submit" value="form" class="btn btn-custom newsletter-button"><?= trans("join"); ?></button>
</div>
<input type="text" name="url">
</form>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="footer-copyright">
<div class="container-xl">
<div class="row align-items-center">
<div class="col-sm-12 col-md-6">
<div class="copyright text-start">
<?= esc($baseSettings->copyright); ?>
</div>
</div>
<div class="col-sm-12 col-md-6">
<div class="nav-footer text-end">
<ul>
<?php if (!empty($menuLinks)):
foreach ($menuLinks as $item):
if ($item->location == "footer"):?>
<li><a href="<?= generateNavItemUrl($item); ?>"><?= esc($item->title); ?> </a></li>
<?php endif;
endforeach;
endif; ?>
</ul>
</div>
</div>
</div>
</div>
</div>
</footer>

<button type="button" class="btn-scroll-up" aria-label="Scroll back to top of the page">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="m18 15-6-6-6 6"/>
</svg>
</button>

<?= loadCommonView("partials/_cookies_warning"); ?>

<?php if ((int)$config->g_analytics_status === 1):
echo loadCommonView("partials/_google_analytics");
endif; ?>

<script src="<?= base_url('assets/common/js/plugins.js'); ?>" defer></script>
<script src="<?= base_url('assets/vendor/bootstrap/js/bootstrap.bundle.min.js'); ?>" defer></script>
<script src="<?= base_url('assets/common/js/main.min.js'); ?>" defer></script>
<?php if ((int)$config->pwa_status === 1):
echo loadCommonView("partials/_pwa");
endif; ?>
<?= $config->custom_footer_codes; ?>

<?= $this->renderSection('scripts'); ?>

<!-- Verification Modal HTML -->
<div class="modal fade" id="verificationModal" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-sm">
        <div class="modal-content text-center">
            <div class="modal-header border-0 pb-0 justify-content-end">
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body pt-0 pb-4 px-4">
                <div id="modalBadgeIcon" class="mb-3 d-flex justify-content-center"></div>
                <h4 id="modalBadgeTitle" class="fw-bold mb-1 text-dark">Verified Account</h4>
                <p class="text-muted fs-7 mb-3">Verified on: <span id="modalBadgeDate" class="fw-semibold"></span></p>
                
                <!-- Description Box -->
                <div id="modalBadgeDesc" class="p-3 rounded text-dark fs-6" style="background-color: #f8f9fa; line-height: 1.5;"></div>
            </div>
        </div>
    </div>
</div>

<!-- Modal Script -->
<script>
document.addEventListener('DOMContentLoaded', function () {
    var verificationModal = document.getElementById('verificationModal');
    
    if (verificationModal) {
        verificationModal.addEventListener('show.bs.modal', function (event) {
            var button = event.relatedTarget;
            
            // Get Data
            var title = button.getAttribute('data-title');
            var date = button.getAttribute('data-date');
            var desc = button.getAttribute('data-desc');
            var iconHtml = button.innerHTML;
            
            // Set Data
            document.getElementById('modalBadgeTitle').textContent = title;
            document.getElementById('modalBadgeDate').textContent = date;
            document.getElementById('modalBadgeDesc').textContent = desc;
            
            var iconContainer = document.getElementById('modalBadgeIcon');
            iconContainer.innerHTML = iconHtml;
            var svg = iconContainer.querySelector('svg');
            if(svg) {
                svg.style.width = '50px';
                svg.style.height = '50px';
            }
        });
    }
});
</script>
</body>
</html>