<?php if (isLoggedIn()): ?>
    </main><!-- Close main-content -->
<?php endif; ?>

<footer class="footer mt-auto py-4 bg-white border-top">
    <div class="container-fluid px-md-4 text-center">
        <div class="d-flex flex-column align-items-center">
            <?php if (!empty($sys_settings['site_footer'])): ?>
                <div class="mb-3 text-secondary" style="max-width: 800px; line-height: 1.6;">
                    <?= nl2br(htmlspecialchars($sys_settings['site_footer'])) ?>
                </div>
            <?php endif; ?>
            
            <span class="text-muted small mb-1">
                &copy; <?= date('Y') ?> <?= htmlspecialchars($sys_settings['site_name']) ?>. جميع الحقوق محفوظة.
            </span>
            <div class="d-flex align-items-center gap-3">
                <span class="badge bg-secondary opacity-50 fw-normal" style="font-size: 0.65rem;">نسخة النظام 1.3.0</span>
                <?php if (isAdmin()): ?>
                <a href="charity-settings.php" onclick="localStorage.setItem('activeSettingsTab', '#general');" class="text-muted text-decoration-none small hover-primary border-start ps-3">
                    <i class="fas fa-cog me-1"></i> الإعدادات
                </a>
                <a href="charity-settings.php#logs" onclick="localStorage.setItem('activeSettingsTab', '#logs');" class="text-muted text-decoration-none small hover-primary border-start ps-3">
                    <i class="fas fa-history me-1"></i> سجل المراسلات
                </a>
                <?php endif; ?>
            </div>
        </div>
    </div>
</footer>

<style>
    .hover-primary:hover {
        color: #0d6efd !important;
    }
    .footer .border-start {
        border-color: rgba(0,0,0,0.1) !important;
    }
    /* TinyMCE Fixes for Bootstrap Modals */
    .tox-tinymce-aux {
        z-index: 9999 !important;
    }
</style>

<!-- Bootstrap Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<!-- TinyMCE Rich Text Editor -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.2/tinymce.min.js"></script>
<!-- SweetAlert2 -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Main App JS -->
<script src="assets/js/main.js?v=<?= time() ?>"></script>
</body>
</html>
<?php 
if (ob_get_level() > 0) {
    ob_end_flush();
}
?>