<?php
/**
 * SMM Paket Satış Scripti - Footer
 * @version 1.0.1
 */

// Footer'da gösterilecek sayfaları çek
$footerPages = [];
try {
    $footerPages = $db->query("SELECT title, slug FROM pages WHERE is_active = 1 AND show_in_footer = 1 ORDER BY sort_order ASC")->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {}

// Null-safe helper
function footerSafeGet($settings, $key, $default = '') {
    $value = $settings->get($key, $default);
    return $value !== null ? $value : $default;
}
?>

</main>

<style>
/* Footer */
.footer {
    background: linear-gradient(180deg, #0a0f1a 0%, #050810 100%);
    border-top: 1px solid rgba(255,255,255,0.05);
    padding: 60px 0 0;
    margin-top: 80px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1.5fr;
    gap: 40px;
}

.footer-brand {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 15px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.footer-brand i { color: var(--primary); }
.footer-brand img { height: 40px; }

.footer-text {
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.7;
}

.footer-social {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.footer-social a {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    transition: all 0.3s;
    text-decoration: none;
}

.footer-social a:hover { 
    transform: translateY(-3px); 
    color: #fff; 
}

.footer-social a.instagram:hover { background: linear-gradient(45deg, #f09433, #dc2743, #bc1888); }
.footer-social a.whatsapp:hover { background: #25d366; }
.footer-social a.telegram:hover { background: #0088cc; }
.footer-social a.twitter:hover { background: #1DA1F2; }
.footer-social a.facebook:hover { background: #1877F2; }
.footer-social a.youtube:hover { background: #FF0000; }
.footer-social a.tiktok:hover { background: #000; border: 1px solid rgba(255,255,255,0.2); }

.footer-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #fff;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li { margin-bottom: 12px; }

.footer-links a {
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.footer-links a:hover { 
    color: var(--primary); 
    padding-left: 5px; 
}

.footer-links a i {
    font-size: 10px;
    color: var(--primary);
}

.footer-contact {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-contact li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
}

.footer-contact li i {
    width: 36px;
    height: 36px;
    background: rgba(var(--primary-rgb), 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 14px;
    flex-shrink: 0;
}

.footer-contact a { 
    color: rgba(255,255,255,0.6); 
    text-decoration: none;
    transition: all 0.3s; 
}

.footer-contact a:hover { color: var(--primary); }

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.05);
    padding: 20px 0;
    margin-top: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.copyright {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    margin: 0;
}

.footer-bottom-links {
    display: flex;
    gap: 20px;
}

.footer-bottom-links a {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.3s;
}

.footer-bottom-links a:hover { color: var(--primary); }

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--gradient);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 999;
    box-shadow: 0 5px 25px rgba(var(--primary-rgb), 0.3);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover { transform: translateY(-5px); }

/* WhatsApp Float */
.whatsapp-float {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background: #25d366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    box-shadow: 0 5px 25px rgba(37, 211, 102, 0.4);
    z-index: 999;
    transition: all 0.3s;
    text-decoration: none;
    animation: whatsappPulse 2s infinite;
}

.whatsapp-float:hover { 
    transform: scale(1.1); 
    color: #fff;
    animation: none;
}

@keyframes whatsappPulse {
    0%, 100% { box-shadow: 0 5px 25px rgba(37, 211, 102, 0.4); }
    50% { box-shadow: 0 5px 40px rgba(37, 211, 102, 0.7); }
}

/* Responsive */
@media (max-width: 991px) {
    .footer { padding: 50px 0 0; margin-top: 60px; }
    .footer-grid { grid-template-columns: repeat(2, 1fr); gap: 30px; }
}

@media (max-width: 576px) {
    .footer { padding: 40px 0 0; }
    .footer-grid { grid-template-columns: 1fr; gap: 30px; }
    .footer-bottom { flex-direction: column; text-align: center; }
    .footer-bottom-links { justify-content: center; }
    .back-to-top { bottom: 20px; right: 20px; width: 45px; height: 45px; }
    .whatsapp-float { bottom: 20px; left: 20px; width: 55px; height: 55px; font-size: 24px; }
}
</style>

<footer class="footer">
    <div class="container">
        <div class="footer-grid">
            <!-- Marka & Hakkında -->
            <div>
                <a href="<?php echo SITE_URL; ?>" class="footer-brand">
                    <?php $logo = footerSafeGet($settings, 'site_logo'); if ($logo): ?>
                        <img src="<?php echo SITE_URL . '/' . $logo; ?>" alt="<?php echo clean(SITE_NAME); ?>">
                    <?php else: ?>
                        <i class="fas fa-bolt"></i>
                        <?php echo clean(SITE_NAME); ?>
                    <?php endif; ?>
                </a>
                <p class="footer-text"><?php echo clean(footerSafeGet($settings, 'footer_about', 'Sosyal medya paketleri için en güvenilir adres.')); ?></p>
                
                <div class="footer-social">
                    <?php $whatsapp = footerSafeGet($settings, 'whatsapp_number'); if ($whatsapp): ?>
                    <a href="https://wa.me/<?php echo preg_replace('/[^0-9]/', '', $whatsapp); ?>" target="_blank" class="whatsapp" title="WhatsApp">
                        <i class="fab fa-whatsapp"></i>
                    </a>
                    <?php endif; ?>
                    
                    <?php $instagram = footerSafeGet($settings, 'instagram_username'); if ($instagram): ?>
                    <a href="https://instagram.com/<?php echo ltrim($instagram, '@'); ?>" target="_blank" class="instagram" title="Instagram">
                        <i class="fab fa-instagram"></i>
                    </a>
                    <?php endif; ?>
                    
                    <?php $telegram = footerSafeGet($settings, 'telegram_username'); if ($telegram): ?>
                    <a href="https://t.me/<?php echo ltrim($telegram, '@'); ?>" target="_blank" class="telegram" title="Telegram">
                        <i class="fab fa-telegram"></i>
                    </a>
                    <?php endif; ?>
                    
                    <?php $twitter = footerSafeGet($settings, 'twitter_username'); if ($twitter): ?>
                    <a href="https://twitter.com/<?php echo ltrim($twitter, '@'); ?>" target="_blank" class="twitter" title="Twitter">
                        <i class="fab fa-x-twitter"></i>
                    </a>
                    <?php endif; ?>
                    
                    <?php $facebook = footerSafeGet($settings, 'facebook_username'); if ($facebook): ?>
                    <a href="https://facebook.com/<?php echo $facebook; ?>" target="_blank" class="facebook" title="Facebook">
                        <i class="fab fa-facebook-f"></i>
                    </a>
                    <?php endif; ?>
                    
                    <?php $youtube = footerSafeGet($settings, 'youtube_channel'); if ($youtube): ?>
                    <a href="https://youtube.com/<?php echo $youtube; ?>" target="_blank" class="youtube" title="YouTube">
                        <i class="fab fa-youtube"></i>
                    </a>
                    <?php endif; ?>
                    
                    <?php $tiktok = footerSafeGet($settings, 'tiktok_username'); if ($tiktok): ?>
                    <a href="https://tiktok.com/@<?php echo ltrim($tiktok, '@'); ?>" target="_blank" class="tiktok" title="TikTok">
                        <i class="fab fa-tiktok"></i>
                    </a>
                    <?php endif; ?>
                </div>
            </div>
            
            <!-- Hızlı Linkler -->
            <div>
                <h4 class="footer-title">Hızlı Linkler</h4>
                <ul class="footer-links">
                    <li><a href="<?php echo SITE_URL; ?>"><i class="fas fa-chevron-right"></i> Ana Sayfa</a></li>
                    <li><a href="<?php echo SITE_URL; ?>/#packages"><i class="fas fa-chevron-right"></i> Paketler</a></li>
                    <li><a href="<?php echo SITE_URL; ?>/siparis-sorgula.php"><i class="fas fa-chevron-right"></i> Sipariş Sorgula</a></li>
                    <li><a href="<?php echo SITE_URL; ?>/sss.php"><i class="fas fa-chevron-right"></i> SSS</a></li>
                </ul>
            </div>
            
            <!-- Bilgi Sayfaları -->
            <div>
                <h4 class="footer-title">Bilgi</h4>
                <ul class="footer-links">
                    <?php if (!empty($footerPages)): ?>
                        <?php foreach ($footerPages as $page): ?>
                        <li>
                            <a href="<?php echo SITE_URL; ?>/sayfa.php?s=<?php echo clean($page['slug']); ?>">
                                <i class="fas fa-chevron-right"></i> <?php echo clean($page['title']); ?>
                            </a>
                        </li>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <li><a href="<?php echo SITE_URL; ?>/sayfa.php?s=hakkimizda"><i class="fas fa-chevron-right"></i> Hakkımızda</a></li>
                        <li><a href="<?php echo SITE_URL; ?>/sayfa.php?s=kullanim-kosullari"><i class="fas fa-chevron-right"></i> Kullanım Koşulları</a></li>
                        <li><a href="<?php echo SITE_URL; ?>/sayfa.php?s=gizlilik-politikasi"><i class="fas fa-chevron-right"></i> Gizlilik Politikası</a></li>
                        <li><a href="<?php echo SITE_URL; ?>/sayfa.php?s=iade-politikasi"><i class="fas fa-chevron-right"></i> İade Politikası</a></li>
                    <?php endif; ?>
                </ul>
            </div>
            
            <!-- İletişim -->
            <div>
                <h4 class="footer-title">İletişim</h4>
                <ul class="footer-contact">
                    <?php $email = footerSafeGet($settings, 'contact_email'); if ($email): ?>
                    <li>
                        <i class="fas fa-envelope"></i>
                        <a href="mailto:<?php echo clean($email); ?>"><?php echo clean($email); ?></a>
                    </li>
                    <?php endif; ?>
                    
                    <?php $phone = footerSafeGet($settings, 'contact_phone'); if ($phone): ?>
                    <li>
                        <i class="fas fa-phone"></i>
                        <a href="tel:<?php echo preg_replace('/[^0-9+]/', '', $phone); ?>"><?php echo clean($phone); ?></a>
                    </li>
                    <?php endif; ?>
                    
                    <?php if ($whatsapp): ?>
                    <li>
                        <i class="fab fa-whatsapp"></i>
                        <a href="https://wa.me/<?php echo preg_replace('/[^0-9]/', '', $whatsapp); ?>" target="_blank">WhatsApp Destek</a>
                    </li>
                    <?php endif; ?>
                    
                    <?php $address = footerSafeGet($settings, 'contact_address'); if ($address): ?>
                    <li>
                        <i class="fas fa-map-marker-alt"></i>
                        <span><?php echo clean($address); ?></span>
                    </li>
                    <?php endif; ?>
                </ul>
            </div>
        </div>
        
        <!-- Bottom -->
        <div class="footer-bottom">
            <p class="copyright"><?php echo clean(footerSafeGet($settings, 'footer_text', '© ' . date('Y') . ' ' . SITE_NAME . '. Tüm hakları saklıdır.')); ?></p>
            <div class="footer-bottom-links">
                <a href="<?php echo SITE_URL; ?>/sayfa.php?s=gizlilik-politikasi">Gizlilik</a>
                <a href="<?php echo SITE_URL; ?>/sayfa.php?s=kullanim-kosullari">Koşullar</a>
                <a href="<?php echo SITE_URL; ?>/sss.php">Yardım</a>
            </div>
        </div>
    </div>
</footer>

<!-- Back to Top -->
<button id="backToTop" class="back-to-top"><i class="fas fa-chevron-up"></i></button>

<!-- WhatsApp Float -->
<?php 
$whatsappEnabled = footerSafeGet($settings, 'footer_whatsapp_enabled', '1');
$whatsappNumber = footerSafeGet($settings, 'whatsapp_number');
if ($whatsappEnabled == '1' && $whatsappNumber): 
?>
<a href="https://wa.me/<?php echo preg_replace('/[^0-9]/', '', $whatsappNumber); ?>" class="whatsapp-float" target="_blank" title="WhatsApp ile iletişime geçin">
    <i class="fab fa-whatsapp"></i>
</a>
<?php endif; ?>

<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<?php if (file_exists(__DIR__ . '/assets/js/aos.js')): ?>
<script src="<?php echo SITE_URL; ?>/assets/js/aos.js"></script>
<?php else: ?>
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<?php endif; ?>

<script>
const SITE_URL = '<?php echo SITE_URL; ?>';

// AOS Init
if (typeof AOS !== 'undefined') {
    AOS.init({ duration: 800, once: true, offset: 100 });
}

// Preloader
window.addEventListener('load', function() {
    var preloader = document.getElementById('preloader');
    if (preloader) { 
        preloader.classList.add('fade-out'); 
        setTimeout(function() { preloader.style.display = 'none'; }, 500); 
    }
});

// Navbar Scroll
window.addEventListener('scroll', function() {
    var nav = document.getElementById('navbar');
    if (nav) nav.classList.toggle('scrolled', window.scrollY > 50);
});

// Back to Top
var backBtn = document.getElementById('backToTop');
if (backBtn) {
    window.addEventListener('scroll', function() { 
        backBtn.classList.toggle('show', window.scrollY > 300); 
    });
    backBtn.addEventListener('click', function() { 
        window.scrollTo({ top: 0, behavior: 'smooth' }); 
    });
}

// Flash auto hide
document.querySelectorAll('.flash-toast .alert').forEach(function(el) {
    setTimeout(function() { 
        if (el.classList.contains('show')) {
            el.classList.remove('show'); 
        }
    }, 5000);
});
</script>

</body>
</html>