<?php
// ১. ডাটাবেস কানেকশন চেক (যদি না থাকে)
if(!isset($conn) && file_exists('config.php')) include 'config.php';

// ২. সেটিংস নিশ্চিত করা (যদি header.php তে লোড না হয়ে থাকে)
if(!isset($theme)) {
    $theme_res = $conn->query("SELECT * FROM site_settings WHERE id=1");
    $theme = $theme_res->fetch_assoc();
}
?>

<style>
    /* --- FOOTER CONTAINER --- */
    .main-footer {
        background: <?= $theme['footer_color'] ?>;
        border-top: 2px solid <?= $theme['effect_color'] ?>;
        padding: 30px 0 20px 0;
        margin-top: auto;
        color: #ccc;
        font-family: 'Segoe UI', sans-serif;
        position: relative;
        z-index: 100;
        backdrop-filter: blur(10px);
        box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
        text-align: center; /* মোবাইলে ডিফল্ট সেন্টার */
    }

    /* --- 1. COPYRIGHT TEXT --- */
    .copyright {
        font-size: 13px;
        opacity: 0.8;
        font-weight: 500;
        margin-bottom: 15px;
        letter-spacing: 0.5px;
    }
    .copyright span { color: <?= $theme['effect_color'] ?>; font-weight: bold; text-transform: uppercase; }

    /* --- 2. SECURITY BADGES --- */
    .trust-badges {
        display: flex;
        justify-content: center;
        gap: 10px;
        flex-wrap: wrap;
        margin-bottom: 15px;
    }
    .t-badge {
        font-size: 11px;
        background: rgba(255,255,255,0.08);
        padding: 6px 15px;
        border-radius: 50px;
        border: 1px solid rgba(255,255,255,0.15);
        display: flex;
        align-items: center;
        gap: 6px;
        color: #fff;
        transition: 0.3s;
    }
    .t-badge i { color: <?= $theme['effect_color'] ?>; font-size: 13px; }
    .t-badge:hover {
        border-color: <?= $theme['effect_color'] ?>;
        background: rgba(255,255,255,0.15);
        transform: translateY(-2px);
    }

    /* --- 3. SOCIAL ICONS --- */
    .f-social {
        display: flex;
        gap: 12px;
        justify-content: center;
    }
    .f-social a {
        width: 38px; height: 38px;
        display: flex; align-items: center; justify-content: center;
        background: rgba(255,255,255,0.1);
        border-radius: 50%;
        color: #fff;
        text-decoration: none;
        transition: 0.3s;
        font-size: 16px;
    }
    .f-social a:hover {
        background: <?= $theme['effect_color'] ?>;
        color: #000;
        box-shadow: 0 0 15px <?= $theme['effect_color'] ?>;
        transform: scale(1.1);
    }

    /* --- 4. APP DOWNLOAD BUTTON (MOBILE ONLY) --- */
    .mobile-app-container {
        display: block;
        width: 100%;
        margin-top: 25px;
        padding-top: 20px;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    .app-btn {
        background: linear-gradient(90deg, <?= $theme['effect_color'] ?>, #000);
        border: 1px solid <?= $theme['effect_color'] ?>;
        color: #fff !important;
        padding: 12px 0;
        border-radius: 50px;
        font-weight: bold;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 90%;
        max-width: 350px;
        margin: 0 auto;
        box-shadow: 0 0 20px rgba(0,0,0,0.5);
        animation: pulse 2s infinite;
        font-size: 15px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
    
    @keyframes pulse { 
        0% { box-shadow: 0 0 0 0 <?= $theme['effect_color'] ?>60; } 
        70% { box-shadow: 0 0 0 10px rgba(0,0,0,0); } 
        100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } 
    }

    /* --- DESKTOP VIEW --- */
    @media (min-width: 768px) {
        .main-footer { text-align: left; padding: 15px 0; }
        .footer-row { display: flex; align-items: center; justify-content: space-between; }
        .copyright { margin-bottom: 0; }
        .trust-badges { margin-bottom: 0; }
        .f-social { justify-content: flex-end; }
        .mobile-app-container { display: none !important; }
    }
</style>

<footer class="main-footer">
    <div class="container">
        
        <!-- Desktop Layout Row -->
        <div class="footer-row">
            
            <!-- LEFT: Copyright -->
            <div class="copyright">
                &copy; <?= date('Y') ?> <span><?= htmlspecialchars($theme['site_title']) ?></span>. All Rights Reserved.
            </div>

            <!-- CENTER: Trust Badges -->
            <div class="trust-badges">
                <div class="t-badge"><i class="fas fa-shield-alt"></i> 100% Secure</div>
                <div class="t-badge"><i class="fas fa-bolt"></i> Fast Delivery</div>
                <div class="t-badge"><i class="fas fa-headset"></i> 24/7 Support</div>
            </div>

            <!-- RIGHT: Social Links -->
            <div class="f-social">
                <?php if($theme['social_fb']!='#') echo '<a href="'.$theme['social_fb'].'" target="_blank"><i class="fab fa-facebook-f"></i></a>'; ?>
                <?php if($theme['social_tg']!='#') echo '<a href="'.$theme['social_tg'].'" target="_blank"><i class="fab fa-telegram-plane"></i></a>'; ?>
                <?php if($theme['social_yt']!='#') echo '<a href="'.$theme['social_yt'].'" target="_blank"><i class="fab fa-youtube"></i></a>'; ?>
                <?php if($theme['social_ds']!='#') echo '<a href="'.$theme['social_ds'].'" target="_blank"><i class="fab fa-discord"></i></a>'; ?>
            </div>

        </div>

        <!-- APP DOWNLOAD BUTTON (Mobile) -->
        <?php if(!empty($theme['app_link']) && $theme['app_link'] != '#'): ?>
            <div class="mobile-app-container">
                <a href="<?= $theme['app_link'] ?>" class="app-btn" target="_blank">
                    <i class="fab fa-android fa-lg"></i> Download Our App
                </a>
            </div>
        <?php endif; ?>

    </div>
</footer>

<!-- JS Library (Bootstrap) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>