<?php
require_once '../config/database.php';
require_once '../includes/functions.php';
$pageTitle = 'Videos';
include 'header.php';

$conn = getConnection();
$videos = $conn->query("SELECT * FROM videos WHERE status='active' ORDER BY created_at DESC");
?>
<div class="container">
    <div class="card">
        <h3>🎥 Watch & Earn</h3>
        <div class="row">
            <?php while ($video = $videos->fetch_assoc()): ?>
            <div class="col-md-4">
                <div class="card">
                    <h4><?php echo htmlspecialchars($video['title']); ?></h4>
                    <p>Duration: <?php echo $video['duration']; ?>s</p>
                    <div style="font-size:20px;font-weight:700;color:#48bb78">Ksh <?php echo number_format($video['reward'], 2); ?></div>
                    <a href="<?php echo htmlspecialchars($video['video_url']); ?>" target="_blank" class="btn btn-primary" style="margin-top:10px">Watch Video</a>
                </div>
            </div>
            <?php endwhile; ?>
        </div>
    </div>
</div>
<?php include 'footer.php'; ?>
