<?php
require_once __DIR__ . '/../functions.php';
$siteName = get_setting('site_name', 'Tumaini Cyber');
$siteFooterText = get_setting('site_footer', 'Premium tech consultancy and digital engineering for ambitious brands.');
$siteCopyright = get_setting('site_copyright', '© Tumaini Cyber ' . date('Y'));
$siteEmail = get_setting('site_email', 'info@tumainicyber.com');
$sitePhone = get_setting('site_phone', '+254759607619');
$siteWhatsapp = get_setting('site_whatsapp', '+254759607619');
$year = date('Y');
$socialLinks = [
    ['label' => 'LinkedIn', 'url' => get_setting('social_linkedin', '#')],
    ['label' => 'Twitter', 'url' => get_setting('social_twitter', '#')],
    ['label' => 'Facebook', 'url' => get_setting('social_facebook', '#')],
];
$footerServices = [];
if (table_exists('services')) {
    $footerServices = pdo()->query('SELECT title FROM services WHERE status = "Published" ORDER BY sort_order, id LIMIT 6')->fetchAll();
}
?>
<footer class="site-footer">
    <div class="footer-grid">
        <div class="footer-branding">
            <span class="footer-logo"><?= clean($siteName) ?></span>
            <p><?= clean($siteFooterText) ?></p>
        </div>
        <div>
            <h3>Navigation</h3>
            <ul class="footer-links">
                <li><a href="index.php">Home</a></li>
                <li><a href="about.php">About</a></li>
                <li><a href="services.php">Services</a></li>
                <li><a href="portfolio.php">Portfolio</a></li>
            </ul>
        </div>
        <div>
            <h3>Services</h3>
            <ul class="footer-links">
                <?php if (!empty($footerServices)): ?>
                    <?php foreach ($footerServices as $service): ?>
                        <li><?= clean($service['title']) ?></li>
                    <?php endforeach; ?>
                <?php else: ?>
                    <li>Cyber Assistant Services</li>
                    <li>Software & Web Development</li>
                    <li>Branding & Design</li>
                    <li>Digital Marketing</li>
                    <li>Media Production</li>
                    <li>Event & Technical Support</li>
                <?php endif; ?>
            </ul>
        </div>
        <div>
            <h3>Contact</h3>
            <ul class="footer-links footer-contact">
                <li><a href="mailto:<?= clean($siteEmail) ?>"><?= clean($siteEmail) ?></a></li>
                <li><a href="tel:<?= clean(preg_replace('/[^0-9+]/', '', $sitePhone)) ?>"><?= clean($sitePhone) ?></a></li>
                <li><a href="https://wa.me/<?= clean(preg_replace('/[^0-9]/', '', $siteWhatsapp)) ?>">WhatsApp</a></li>
            </ul>
        </div>
    </div>
    <div class="footer-bottom">
        <p><?= clean($siteCopyright) ?></p>
    </div>
</footer>
