<style>
    /* ==========================================
       Footer & Floating Styles
    ============================================= */
    .ahmad-footer { background: linear-gradient(135deg, #021a14, #01120d); color: rgba(255,255,255,0.7); padding: 60px 0 0; border-top: 4px solid var(--accent); }
    .footer-logo img { height: 55px; border-radius: 8px; box-shadow: 0 0 15px rgba(212,175,55,0.25); transition: 0.3s; }
    .footer-logo img:hover { transform: scale(1.05); }
    .footer-title { font-size: 20px; font-weight: 700; color: var(--white); margin-bottom: 25px; display: flex; align-items: center; }
    .footer-title::before { content: ''; width: 6px; height: 18px; background: var(--accent); border-radius: 3px; margin-right: 10px; }
    .footer-text { font-size: 15px; line-height: 1.6; }
    .footer-links { list-style: none; padding: 0; }
    .footer-links li { margin-bottom: 12px; }
    .footer-links a { color: rgba(255,255,255,0.7); text-decoration: none; transition: 0.3s; }
    .footer-links a:hover { color: var(--accent); transform: translateX(5px); display: inline-block; }
    .footer-contact { padding: 0; }
    .footer-contact li { list-style: none; margin-bottom: 15px; display: flex; align-items: flex-start; }
    .footer-contact i { color: var(--accent); margin-right: 12px; margin-top: 4px; }
    .social-btn { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.05); display: flex; align-items: center; justify-content: center; transition: 0.3s; color: white; text-decoration: none; }
    .social-btn:hover { background: var(--accent); color: #000; transform: translateY(-4px); }
    .footer-bottom { margin-top: 40px; padding: 20px 0; background: #010f0b; border-top: 1px solid rgba(255,255,255,0.05); font-size: 14px; }

    /* Scroll Buttons */
    .scroll-buttons { position: fixed; bottom: 30px; right: 30px; display: flex; flex-direction: column; gap: 12px; z-index: 999; }
    .scroll-btn { width: 45px; height: 45px; border-radius: 50%; background: var(--accent); color: var(--primary-dark); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); transition: 0.4s; opacity: 0; visibility: hidden; transform: translateY(20px); }
    .scroll-btn.show { opacity: 1; visibility: visible; transform: translateY(0); }
    .scroll-btn:hover { background: var(--primary-dark); color: var(--accent); }

    /* Floating WhatsApp */
    .floating-wa { position: fixed; bottom: 30px; left: 30px; z-index: 1000; display: flex; align-items: center; gap: 15px; text-decoration: none; }
    .wa-icon-wrapper { width: 60px; height: 60px; background-color: #25D366; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 35px; box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4); position: relative; z-index: 2; transition: 0.3s; }
    .wa-icon-wrapper::before { content: ''; position: absolute; width: 100%; height: 100%; background-color: #25D366; border-radius: 50%; z-index: -1; opacity: 0.7; animation: wa-pulse 1.5s infinite; }
    .floating-wa:hover .wa-icon-wrapper { transform: scale(1.1); }
    .wa-text { background: white; color: var(--primary-dark); padding: 8px 18px; border-radius: 30px; font-size: 14px; font-weight: 700; box-shadow: 0 5px 15px rgba(0,0,0,0.1); opacity: 0; transform: translateX(-20px); transition: 0.3s; pointer-events: none; border: 1px solid rgba(37, 211, 102, 0.2); }
    .floating-wa:hover .wa-text { opacity: 1; transform: translateX(0); }

    @keyframes wa-pulse { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(1.6); opacity: 0; } }

    @media (max-width: 768px) {
        .scroll-buttons { bottom: 20px; right: 20px; gap: 10px; }
        .scroll-btn { width: 40px; height: 40px; font-size: 16px; }
        .floating-wa { bottom: 20px; left: 20px; }
        .wa-icon-wrapper { width: 50px; height: 50px; font-size: 28px; }
        .wa-text { display: none; }
    }
</style>

<?php
// Smart Logo Path Fixer for Footer
$f_raw_logo = $settings['site_logo'] ?? '';
$f_logo = 'https://ahmadonlineacademy.com/assets/images/logo.png'; 
if (!empty($f_raw_logo)) {
    if (strpos($f_raw_logo, 'http') === 0) { $f_logo = $f_raw_logo; } 
    else { $f_logo = 'https://ahmadonlineacademy.com/' . ltrim(str_replace('../', '', $f_raw_logo), '/'); }
}
?>

<a href="https://wa.me/<?= htmlspecialchars($settings['contact_whatsapp'] ?? '8801815244716') ?>?text=Assalamu%20Alaikum,%20I%20have%20a%20query%20about%20<?= urlencode($settings['site_title'] ?? 'Ahmad Academy') ?>." target="_blank" class="floating-wa">
    <div class="wa-icon-wrapper"><i class="fab fa-whatsapp"></i></div>
    <span class="wa-text">Chat with us!</span>
</a>

<div class="scroll-buttons">
    <button id="scrollTopBtn" class="scroll-btn" title="Scroll to Top"><i class="fas fa-arrow-up"></i></button>
    <button id="scrollBottomBtn" class="scroll-btn" title="Scroll to Bottom"><i class="fas fa-arrow-down"></i></button>
</div>

<footer class="ahmad-footer">
    <div class="container">
        <div class="row g-5">
            
            <div class="col-lg-4 col-md-6">
                <div class="footer-logo mb-3">
                    <a href="https://ahmadonlineacademy.com/">
                        <img src="<?= htmlspecialchars($f_logo) ?>" alt="Ahmad Academy Logo">
                    </a>
                </div>
                <p class="footer-text mt-3"><?= htmlspecialchars($settings['footer_about'] ?? 'Ahmad Online Academy is a dedicated Islamic learning platform committed to spreading authentic knowledge worldwide.'); ?></p>
                <div class="d-flex gap-2 mt-4">
                    <?php if(!empty($settings['social_facebook'])): ?>
                        <a href="<?= htmlspecialchars($settings['social_facebook']) ?>" target="_blank" class="social-btn"><i class="fab fa-facebook-f"></i></a>
                    <?php endif; ?>
                    <?php if(!empty($settings['social_youtube'])): ?>
                        <a href="<?= htmlspecialchars($settings['social_youtube']) ?>" target="_blank" class="social-btn"><i class="fab fa-youtube"></i></a>
                    <?php endif; ?>
                    <?php if(!empty($settings['social_instagram'])): ?>
                        <a href="<?= htmlspecialchars($settings['social_instagram']) ?>" target="_blank" class="social-btn"><i class="fab fa-instagram"></i></a>
                    <?php endif; ?>
                    <?php if(!empty($settings['social_linkedin'])): ?>
                        <a href="<?= htmlspecialchars($settings['social_linkedin']) ?>" target="_blank" class="social-btn"><i class="fab fa-linkedin"></i></a>
                    <?php endif; ?>
                </div>
            </div>
            
            <div class="col-lg-2 col-md-6">
                <h4 class="footer-title">Quick Links</h4>
                <ul class="footer-links">
                    <li><a href="https://ahmadonlineacademy.com/">Home</a></li>
                    <li><a href="about-us">About Us</a></li>
                    <li><a href="courses">Our Courses</a></li>
                    <li><a href="admission">Admission</a></li>
                </ul>
            </div>
            
            <div class="col-lg-3 col-md-6">
                <h4 class="footer-title">Contact Info</h4>
                <ul class="footer-contact">
                    <li><i class="fas fa-map-marker-alt"></i> <?= htmlspecialchars($settings['contact_location'] ?? 'Online Worldwide') ?></li>
                    <li><i class="fas fa-envelope"></i> <?= htmlspecialchars($settings['contact_email'] ?? 'info@ahmadonlineacademy.com') ?></li>
                    <li><i class="fas fa-phone-alt"></i> <?= htmlspecialchars($settings['contact_phone'] ?? '+880 1815 244 716') ?></li>
                </ul>
            </div>
            
            <div class="col-lg-3 col-md-6">
                <h4 class="footer-title">Support</h4>
                <ul class="footer-links">
                    <li><a href="contact">Contact Support</a></li>
                    <li><a href="login">Student Portal</a></li>
                    <li><a href="teacher/login">Teacher Portal</a></li>
                    <li><a href="privacy-policy">Privacy Policy</a></li>
                </ul>
            </div>
            
        </div>
    </div>
    
    <div class="footer-bottom">
        <div class="container">
            <div class="row align-items-center">
                <div class="col-md-6 text-center text-md-start mb-2 mb-md-0">
                    <?= htmlspecialchars_decode($settings['copyright_text'] ?? '&copy; ' . date('Y') . ' Ahmad Academy. All Rights Reserved.') ?>
                </div>
                <div class="col-md-6 text-center text-md-end">
                    Powered by <a href="#" style="color: var(--accent); font-weight: bold; text-decoration: none; transition: 0.3s;" onmouseover="this.style.color='#fff'" onmouseout="this.style.color='var(--accent)'">Zenlab Solution</a>
                </div>
            </div>
        </div>
    </div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

<script>
    document.addEventListener("DOMContentLoaded", function() {
        const scrollTopBtn = document.getElementById("scrollTopBtn");
        const scrollBottomBtn = document.getElementById("scrollBottomBtn");

        window.addEventListener("scroll", () => {
            if (window.scrollY > 200) scrollTopBtn.classList.add("show");
            else scrollTopBtn.classList.remove("show");

            if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight - 50) scrollBottomBtn.classList.remove("show");
            else scrollBottomBtn.classList.add("show");
        });

        scrollTopBtn.addEventListener("click", () => { window.scrollTo({ top: 0, behavior: "smooth" }); });
        scrollBottomBtn.addEventListener("click", () => { window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" }); });

        if ((window.innerHeight + window.scrollY) < document.body.offsetHeight - 50) scrollBottomBtn.classList.add("show");
    });
</script>

</body>
</html>