<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Direct - Kaubuntu.re</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">
    
    <!-- Favicons -->
    <link rel="apple-touch-icon" sizes="180x180" href="img/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">
    <link rel="manifest" href="site.webmanifest">
    <link rel="icon" type="image/x-icon" href="img/favicon.ico">
    <meta name="theme-color" content="#ffffff">
</head>
<body>
    <?php
    // Inclure la configuration
    require_once 'includes/config.php';
    ?>
    <?php include 'includes/sidebar.php'; ?>
    <!-- Contenu principal -->
    <div class="main-content">
        <?php include 'includes/header.php'; ?>
        
        <!-- Section Direct -->
        <div class="live-page">
            <div class="section-header">
                <div class="section-logo">
                    <img src="img/logo.png" alt="Kaubuntu.re">
                </div>
                <h2 class="section-title">Diffusion en direct</h2>
            </div>
            
            <div class="live-container">
                <?php 
                // Vérifier s'il y a un direct en cours
                $liveStream = getLiveStream();
                
                if ($liveStream) {
                    // Afficher le direct en cours
                    ?>
                    <div class="live-badge large">
                        <i class="fas fa-circle"></i> EN DIRECT
                    </div>
                    <div class="live-player">
                        <iframe 
                            src="<?php echo PEERTUBE_URL; ?>/videos/embed/<?php echo $liveStream['id']; ?>?autoplay=1" 
                            frameborder="0" 
                            allowfullscreen="allowfullscreen"
                            allow="autoplay; fullscreen"
                            title="<?php echo htmlspecialchars($liveStream['title']); ?>">
                        </iframe>
                    </div>
                    <div class="live-info">
                        <h1 class="live-title"><?php echo htmlspecialchars($liveStream['title']); ?></h1>
                        <div class="live-channel-info">
                            <?php if (strpos($liveStream['channelAvatar'], 'default-avatar.png') !== false || empty($liveStream['channelAvatar'])): ?>
                                <div class="channel-avatar-placeholder">
                                    <i class="fas fa-user-circle"></i>
                                </div>
                            <?php else: ?>
                                <img src="<?php echo $liveStream['channelAvatar']; ?>" alt="<?php echo $liveStream['channel']; ?>" class="channel-avatar">
                            <?php endif; ?>
                            <span class="channel-name"><?php echo $liveStream['channel']; ?></span>
                        </div>
                        <?php if (!empty($liveStream['description'])): ?>
                        <div class="live-description">
                            <?php echo markdown_to_html($liveStream['description']); ?>
                        </div>
                        <?php endif; ?>
                    </div>
                <?php 
                } else {
                    // Aucun direct en cours
                    ?>
                    <div class="no-live-message">
                        <i class="fas fa-tv"></i>
                        <h2>Aucun direct en cours</h2>
                        <p>Revenez plus tard pour découvrir nos prochaines diffusions en direct.</p>
                        <a href="index.php" class="btn-primary">Retour à l'accueil</a>
                    </div>
                <?php
                }
                ?>
            </div>
        </div>
    </div>
    <?php include 'includes/footer.php'; ?>
    <?php include 'includes/mobile-menu.php'; ?>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script src="js/main.js"></script>
</body>
</html> 