<?php
// /includes/footer.php

// Busca as configurações necessárias para o rodapé
$stmtFooter = $pdo->query("SELECT chave, valor FROM configs WHERE chave IN ('nome_artista', 'link_facebook', 'link_instagram', 'link_youtube')");
$footer_cfg = [];
while($r = $stmtFooter->fetch()) {
    $footer_cfg[$r['chave']] = $r['valor'];
}

$nome_rodape = $footer_cfg['nome_artista'] ?? 'Artista';
$ano_atual = date('Y'); 
?>

    <footer class="site-footer">
        
        <p class="site-footer-copy">
            &copy; <?= $ano_atual ?> <?= htmlspecialchars($nome_rodape) ?> - Todos os direitos reservados.
        </p>
        
        <div class="social-icons">
            
            <?php if(!empty($footer_cfg['link_facebook'])): ?>
                <a href="<?= htmlspecialchars($footer_cfg['link_facebook']) ?>" target="_blank" rel="noopener noreferrer" aria-label="Facebook">
                    <i class="fab fa-facebook"></i>
                </a>
            <?php endif; ?>

            <?php if(!empty($footer_cfg['link_instagram'])): ?>
                <a href="<?= htmlspecialchars($footer_cfg['link_instagram']) ?>" target="_blank" rel="noopener noreferrer" aria-label="Instagram">
                    <i class="fab fa-instagram"></i>
                </a>
            <?php endif; ?>

            <?php if(!empty($footer_cfg['link_youtube'])): ?>
                <a href="<?= htmlspecialchars($footer_cfg['link_youtube']) ?>" target="_blank" rel="noopener noreferrer" aria-label="YouTube">
                    <i class="fab fa-youtube"></i>
                </a>
            <?php endif; ?>

        </div>
    </footer>

    <script>
        const menuToggle = document.querySelector('.menu-toggle');
        const navLinks = document.querySelector('.nav-links');
        if(menuToggle) {
            menuToggle.addEventListener('click', () => {
                navLinks.classList.toggle('active');
            });
        }
    </script>
</body>
</html>
