<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Kaubuntu.re - Plateforme Multimédia</title>
    <link rel="stylesheet" href="css/styles.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link rel="stylesheet" href="css/mastodon-timeline.min.css">
</head>
<body>
    <?php
    // Inclure la configuration
    require_once 'includes/config.php';
    ?>
    
    <!-- Sidebar de navigation -->
    <div class="sidebar">
        <a href="index.php" class="logo">
            <img src="img/logo.png" alt="Kaubuntu.re">
        </a>
        
        <nav class="sidebar-nav">
            <a href="index.php" class="nav-item" data-title="Accueil">
                <i class="fas fa-home"></i> <span>Accueil</span>
            </a>
            <a href="#" class="nav-item" data-title="Direct">
                <i class="fas fa-broadcast-tower"></i> <span>Direct</span>
            </a>
            
            <div class="nav-divider"></div>
            
            <a href="#" class="nav-item" data-title="Explorer">
                <i class="fas fa-compass"></i> <span>Explorer</span>
            </a>
            <a href="#" class="nav-item" data-title="Actualité">
                <i class="fas fa-globe"></i> <span>Actualité</span>
            </a>
            <a href="#" class="nav-item" data-title="Musique">
                <i class="fas fa-music"></i> <span>Musique</span>
            </a>
            <a href="#" class="nav-item" data-title="Histoire">
                <i class="fas fa-monument"></i> <span>Histoire</span>
            </a>
            <a href="#" class="nav-item" data-title="Sport">
                <i class="fas fa-running"></i> <span>Sport</span>
            </a>
            
            <div class="nav-divider"></div>
            
            <div class="category-title">
                <i class="fas fa-hashtag"></i> <span>Hashtags</span>
            </div>
            
            <a href="#" class="tag-item" data-title="Interview">
                <div class="tag-dot"></div> <span>Interview</span>
            </a>
            <a href="#" class="tag-item" data-title="Conférence">
                <div class="tag-dot"></div> <span>Conférence</span>
            </a>
            <a href="#" class="tag-item" data-title="Colonialisme">
                <div class="tag-dot"></div> <span>Colonialisme</span>
            </a>
            <a href="#" class="tag-item" data-title="La Réunion">
                <div class="tag-dot"></div> <span>La Réunion</span>
            </a>
            <a href="#" class="tag-item" data-title="Afrique">
                <div class="tag-dot"></div> <span>Afrique</span>
            </a>
        </nav>
    </div>
    
    <!-- Contenu principal -->
    <div class="main-content">
        <!-- Header avec barre de recherche et icônes -->
        <div class="header">
            <div class="search-container">
                <form action="search.php" method="get">
                    <input type="text" name="q" placeholder="Recherche">
                    <button type="submit"><i class="fas fa-search"></i></button>
                </form>
            </div>
            
            <div class="social-icons">
                <a target="_blank" rel="noreferrer" href="<?php echo FACEBOOK_URL; ?>" class="icon-button"><i class="fab fa-facebook"></i></a>
                <a target="_blank" rel="noreferrer" href="<?php echo YOUTUBE_URL; ?>" class="icon-button"><i class="fab fa-youtube"></i></a>
                <a target="_blank" rel="noreferrer" href="<?php echo INSTAGRAM_URL; ?>" class="icon-button"><i class="fab fa-instagram"></i></a>
                <a target="_blank" rel="noreferrer" href="<?php echo TIKTOK_URL; ?>" class="icon-button"><i class="fab fa-tiktok"></i></a>
                <a href="#" class="icon-button"><i class="fas fa-ellipsis-h"></i></a>
            </div>
            
            <div class="action-icons">
                <a href="#" class="icon-button"><i class="fas fa-film"></i></a>
                <button class="dark-mode-toggle"><i class="fas fa-moon"></i></button>
                <button class="mobile-menu-toggle">
                    <i class="fas fa-bars"></i>
                </button>
            </div>
        </div>
        
        <!-- Hero and Mastodon container -->
        <div class="hero-mastodon-wrapper">
            <!-- Hero Banner -->
            <div class="hero">
                <div class="hero-content">
                    <div class="hero-logo">KAUBUNTU<span class="re">.RE</span></div>
                    <div class="play-button">
                        <i class="fas fa-play"></i>
                    </div>
                </div>
            </div>

            <div id="mt-container" class="mt-container">
                <div class="mt-header">
                    <h2 class="mt-title">Fil d'actualités <i class="fab fa-mastodon"></i></h2>
                </div>
                <div class="mt-body" role="feed">
                    <div class="mt-loading-spinner"></div>
                </div>
            </div>
        </div>

        
        <!-- Hashtags en ligne -->
        <div class="tags-section">
            <a href="#" class="tag">#Justice</a>
            <a href="#" class="tag">#Romain</a>
            <a href="#" class="tag">#Saint-Pierre</a>
            <a href="#" class="tag">#Paris</a>
            <a href="#" class="tag">#Afrique</a>
        </div>
        
        <!-- Section Shorts -->
        <div class="video-section">
            <div class="section-header">
                <div class="section-logo">
                    <img src="img/logo.png" alt="Kaubuntu.re">
                </div>
                <h2 class="section-title">Shorts</h2>
            </div>
            
            <div class="carousel">
                <div class="carousel-container">
                    <?php 
                    // Récupérer les shorts depuis l'API PeerTube
                    $shorts = getShorts();
                    
                    // Traiter le cas où aucun short n'est trouvé
                    if (empty($shorts)) {
                        echo '<div class="no-results">Aucun short disponible pour le moment</div>';
                    } else {
                        foreach ($shorts as $video):
                    ?>
                    <div class="carousel-item">
                        <div class="video-card" data-video-id="<?php echo $video['id']; ?>">
                            <div class="video-thumbnail">
                                <img src="<?php echo $video['thumbnail']; ?>" alt="<?php echo $video['title']; ?>">
                                <div class="video-play-icon">
                                    <i class="fas fa-play-circle"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php 
                        endforeach;
                    }
                    ?>
                </div>
                
                <?php if (!empty($shorts) && count($shorts) > 1): ?>
                <div class="carousel-controls">
                    <?php for ($i = 0; $i < count($shorts); $i++): ?>
                    <div class="carousel-dot <?php echo $i === 0 ? 'active' : ''; ?>"></div>
                    <?php endfor; ?>
                </div>
                <?php endif; ?>
            </div>
        </div>
        
        <!-- Section Dernières vidéos -->
        <div class="video-section">
            <div class="section-header">
                <div class="section-logo">
                    <img src="img/logo.png" alt="Kaubuntu.re">
                </div>
                <h2 class="section-title">Dernières vidéos</h2>
            </div>
            
            <div class="video-grid">
                <?php
                // Récupérer les vidéos récentes depuis l'API PeerTube
                $recentVideos = getRecentVideos();
                
                // Traiter le cas où aucune vidéo n'est trouvée
                if (empty($recentVideos)) {
                    echo '<div class="no-results">Aucune vidéo disponible pour le moment</div>';
                } else {
                    foreach ($recentVideos as $video):
                ?>
                <div class="video-card" data-video-id="<?php echo $video['id']; ?>">
                    <div class="video-thumbnail">
                        <img src="<?php echo $video['thumbnail']; ?>" alt="<?php echo $video['title']; ?>">
                        <div class="video-play-icon">
                            <i class="fas fa-play-circle"></i>
                        </div>
                        <div class="video-duration"><?php echo formatDuration($video['duration']); ?></div>
                    </div>
                    <div class="video-info">
                        <h3 class="video-title"><?php echo $video['title']; ?></h3>
                        <div class="video-channel"><?php echo $video['channel']; ?></div>
                        <div class="video-metadata">
                            <span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span>
                            <span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span>
                        </div>
                    </div>
                </div>
                <?php 
                    endforeach;
                }
                ?>
            </div>
            
            <button class="view-more">Voir plus</button>
        </div>
        
        <!-- Section Tendances -->
        <div class="video-section">
            <div class="section-header">
                <div class="section-logo">
                    <img src="img/logo.png" alt="Kaubuntu.re">
                </div>
                <h2 class="section-title">Tendances</h2>
            </div>
            
            <div class="video-grid">
                <?php
                // Récupérer les vidéos tendances depuis l'API PeerTube
                $trendingVideos = getTrendingVideos();
                
                // Traiter le cas où aucune vidéo n'est trouvée
                if (empty($trendingVideos)) {
                    echo '<div class="no-results">Aucune vidéo disponible pour le moment</div>';
                } else {
                    foreach ($trendingVideos as $video):
                ?>
                <div class="video-card" data-video-id="<?php echo $video['id']; ?>">
                    <div class="video-thumbnail">
                        <img src="<?php echo $video['thumbnail']; ?>" alt="<?php echo $video['title']; ?>">
                        <div class="video-play-icon">
                            <i class="fas fa-play-circle"></i>
                        </div>
                        <div class="video-duration"><?php echo formatDuration($video['duration']); ?></div>
                    </div>
                    <div class="video-info">
                        <h3 class="video-title"><?php echo $video['title']; ?></h3>
                        <div class="video-channel"><?php echo $video['channel']; ?></div>
                        <div class="video-metadata">
                            <span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span>
                            <span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span>
                        </div>
                    </div>
                </div>
                <?php 
                    endforeach;
                }
                ?>
            </div>
            
            <button class="view-more">Voir plus</button>
        </div>
        
        <!-- Sections par catégorie -->
        <?php
        // Récupérer les catégories avec leurs vidéos
        $displayCategories = getDisplayCategories();
        
        // Afficher chaque catégorie qui a des vidéos
        foreach ($displayCategories as $category):
            if (!empty($category['videos'])):
        ?>
        <!-- Section Catégorie: <?php echo $category['name']; ?> -->
        <div class="video-section" data-category-id="<?php echo $category['id']; ?>">
            <div class="section-header">
                <div class="section-logo">
                    <img src="img/logo.png" alt="Kaubuntu.re">
                </div>
                <h2 class="section-title"><?php echo $category['name']; ?></h2>
            </div>
            
            <div class="video-grid">
                <?php foreach ($category['videos'] as $video): ?>
                <div class="video-card" data-video-id="<?php echo $video['id']; ?>">
                    <div class="video-thumbnail">
                        <img src="<?php echo $video['thumbnail']; ?>" alt="<?php echo $video['title']; ?>">
                        <div class="video-play-icon">
                            <i class="fas fa-play-circle"></i>
                        </div>
                        <div class="video-duration"><?php echo formatDuration($video['duration']); ?></div>
                    </div>
                    <div class="video-info">
                        <h3 class="video-title"><?php echo $video['title']; ?></h3>
                        <div class="video-channel"><?php echo $video['channel']; ?></div>
                        <div class="video-metadata">
                            <span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span>
                            <span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span>
                        </div>
                    </div>
                </div>
                <?php endforeach; ?>
            </div>
            
            <button class="view-more">Voir plus</button>
        </div>
        <?php 
            endif;
        endforeach;
        ?>
        
        <!-- Section Tendances Hashtags -->
        <div class="video-section">
            <h2 class="section-title">Tendances</h2>
            
            <div class="tags-section">
                <a href="#" class="tag">#LaRéunion</a>
                <a href="#" class="tag">#Afrique</a>
                <a href="#" class="tag">#Indépendance</a>
                <a href="#" class="tag">#Saint-Pierre</a>
            </div>
        </div>
        
        <!-- Section Informations -->
        <div class="info-section">
            <h2 class="info-header">KA UBUNTU est un mouvement politique indépendantiste et panafricaniste réunionnais qui a 5 objectifs :</h2>
            
            <img src="img/ka-ubuntu-manifesto.png" alt="KA UBUNTU manifesto" class="info-image">
        </div>
        
        <!-- Footer -->
        <div class="footer">
            <div class="footer-logo">
                <img src="img/logo.png" alt="Kaubuntu.re">
            </div>
            
            <div class="footer-social">
                <a target="_blank" rel="noreferrer" href="<?php echo FACEBOOK_URL; ?>"><i class="fab fa-facebook"></i></a>
                <a target="_blank" rel="noreferrer" href="<?php echo YOUTUBE_URL; ?>"><i class="fab fa-youtube"></i></a>
                <a target="_blank" rel="noreferrer" href="<?php echo INSTAGRAM_URL; ?>"><i class="fab fa-instagram"></i></a>
                <a target="_blank" rel="noreferrer" href="<?php echo TWITTER_URL; ?>"><i class="fab fa-twitter"></i></a>
                <a target="_blank" rel="noreferrer" href="<?php echo TIKTOK_URL; ?>"><i class="fab fa-tiktok"></i></a>
            </div>
            
            <div class="footer-contact">CONTACT</div>
            <div class="footer-email">zinfos@kaubuntu.com</div>
        </div>
    </div>
    
    <!-- Menu mobile (masqué par défaut) -->
    <div class="mobile-menu">
        <button class="mobile-menu-close">
            <i class="fas fa-times"></i>
        </button>
        
        <div class="search-container">
            <form action="search.php" method="get">
                <input type="text" name="q" placeholder="Recherche">
                <button type="submit"><i class="fas fa-search"></i></button>
            </form>
        </div>
        
        <a href="index.php" class="nav-item">
            <i class="fas fa-home"></i> Accueil
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-broadcast-tower"></i> Direct
        </a>
        
        <div class="nav-divider"></div>
        
        <a href="#" class="nav-item">
            <i class="fas fa-compass"></i> Explorer
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-globe"></i> Actualité
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-music"></i> Musique
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-monument"></i> Histoire
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-running"></i> Sport
        </a>
    </div>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script src="js/main.js"></script>
    <script src="js/mastodon-timeline.umd.js"></script>
    <script src="js/mastodon-config.php"></script>
</body>
</html> 