<!-- Footer -->
<div class="footer">
    <div class="footer-header">
        <div class="footer-logo">
            <img src="img/logo.png" alt="<?php echo SITE_NAME; ?>">
        </div>

        <div class="footer-contact-info">
            <div class="footer-contact">CONTACT</div>
            <div class="footer-email"><a href="mailto:<?php echo CONTACT_EMAIL; ?>"><?php echo CONTACT_EMAIL; ?></a></div>
        </div>
    </div>

    <div class="footer-columns">
        <div class="footer-column">
            <h3 class="footer-title">Catégories</h3>
            <div>
                <ul class="footer-links">
                    <li><a href="index.php" <?php echo ($currentPage === 'index.php') ? 'class="active"' : ''; ?>>Accueil</a></li>
                    <?php if (!defined('HERO_TYPE') || HERO_TYPE === 'live'): ?>
                    <li><a href="direct.php" <?php echo ($currentPage === 'direct.php') ? 'class="active"' : ''; ?>>Direct</a></li>
                    <?php endif; ?>

                    <?php
                    if (defined('PRIORITY_CATEGORIES') && !empty(PRIORITY_CATEGORIES)) {
                        foreach (PRIORITY_CATEGORIES as $id => $name) {
                            $isActive = ($currentPage === 'categories.php' && $currentCategoryId === $id);
                            echo '<li><a href="categories.php?id=' . $id . '"' . ($isActive ? ' class="active"' : '') . '>' . htmlspecialchars($name) . '</a></li>';
                        }
                    }
                    ?>
                </ul>
            </div>
        </div>

        <div class="footer-column">
            <h3 class="footer-title">Hashtags</h3>
            <div>
                <ul class="footer-links">
                    <?php
                    if (defined('IMPORTANT_TAGS') && !empty(IMPORTANT_TAGS)):
                        foreach (IMPORTANT_TAGS as $tag):
                            $encodedTag = urlencode('#' . $tag);
                            $isActive = ($isTagSearch && strtolower($currentTag) === strtolower($tag));
                    ?>
                    <li><a href="recherche.php?q=<?php echo $encodedTag; ?>" <?php echo $isActive ? 'class="active"' : ''; ?>><?php echo htmlspecialchars($tag); ?></a></li>
                    <?php
                        endforeach;
                    endif;
                    ?>
                </ul>
            </div>
        </div>

        <div class="footer-column">
            <h3 class="footer-title">Informations légales</h3>
            <div>
                <ul class="footer-links">
                    <li><a href="mentions-legales.php" <?php echo ($currentPage === 'mentions-legales.php') ? 'class="active"' : ''; ?>>Mentions légales</a></li>
                    <li>
                        <a href="<?php echo LEGAL_SOURCE_CODE_URL; ?>" target="_blank" rel="noopener noreferrer">
                            <i class="fab fa-git-alt"></i> Code source
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>

    <div class="footer-social">
        <?php if (!empty(MASTODON_URL) && MASTODON_URL !== '#'): ?>
        <a target="_blank" rel="me noreferrer" href="<?php echo MASTODON_URL; ?>"><i class="fab fa-mastodon icon-mastodon"></i></a>
        <?php endif; ?>

        <?php if (!empty(FACEBOOK_URL) && FACEBOOK_URL !== '#'): ?>
        <a target="_blank" rel="noreferrer" href="<?php echo FACEBOOK_URL; ?>"><i class="fab fa-facebook icon-facebook"></i></a>
        <?php endif; ?>

        <?php if (!empty(YOUTUBE_URL) && YOUTUBE_URL !== '#'): ?>
        <a target="_blank" rel="noreferrer" href="<?php echo YOUTUBE_URL; ?>"><i class="fab fa-youtube icon-youtube"></i></a>
        <?php endif; ?>

        <?php if (!empty(INSTAGRAM_URL) && INSTAGRAM_URL !== '#'): ?>
        <a target="_blank" rel="noreferrer" href="<?php echo INSTAGRAM_URL; ?>"><i class="fab fa-instagram icon-instagram"></i></a>
        <?php endif; ?>

        <?php if (!empty(X_URL) && X_URL !== '#'): ?>
        <a target="_blank" rel="noreferrer" href="<?php echo X_URL; ?>"><i class="fab fa-x-twitter icon-x"></i></a>
        <?php endif; ?>

        <?php if (!empty(TIKTOK_URL) && TIKTOK_URL !== '#'): ?>
        <a target="_blank" rel="noreferrer" href="<?php echo TIKTOK_URL; ?>"><i class="fab fa-tiktok icon-tiktok"></i></a>
        <?php endif; ?>
    </div>

    <div class="footer-copyright">
        <?php echo LEGAL_COPYRIGHT; ?> <?php echo date('Y'); ?> - Licence libre <a href="<?php echo LEGAL_LICENSE_URL; ?>" target="_blank" rel="noopener noreferrer"><?php echo LEGAL_LICENSE; ?></a>
    </div>
</div>
