<?php $title = 'Forum - Ghana Anaesthesiologists Society'; ?>
<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-white font-weight-bold"><i class="fas fa-comments mr-2"></i>Forum</h1>
</div>
<div class="row">
    <div class="col-lg-8">
        <h5 class="text-white font-weight-bold mb-3">Categories</h5>
        <?php if (!empty($categories)): ?>
            <?php foreach ($categories as $cat): ?>
            <div class="glass-card mb-3">
                <div class="d-flex justify-content-between align-items-center">
                    <div>
                        <h5 class="font-weight-bold mb-1"><a href="<?= $baseUrl ?>/forum/category/<?= $cat->id ?>" style="color: white;"><?= htmlspecialchars($cat->name) ?></a></h5>
                        <p style="color: rgba(255,255,255,0.6); font-size: 0.9rem; margin: 0;"><?= htmlspecialchars($cat->description ?? '') ?></p>
                    </div>
                    <span class="glass-badge"><?= $cat->topic_count ?? 0 ?> topics</span>
                </div>
            </div>
            <?php endforeach; ?>
        <?php else: ?>
            <div class="empty-state"><i class="fas fa-comments"></i><p>No forum categories yet</p></div>
        <?php endif; ?>
    </div>
    <div class="col-lg-4">
        <div class="glass-card">
            <h5 class="font-weight-bold mb-3">Recent Topics</h5>
            <?php if (!empty($recentTopics)): ?>
                <?php foreach ($recentTopics as $topic): ?>
                <div class="mb-2" style="border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 8px;">
                    <a href="<?= $baseUrl ?>/forum/topic/<?= $topic->id ?>" style="font-size: 0.9rem;"><?= htmlspecialchars($topic->title) ?></a>
                    <small class="d-block" style="color: rgba(255,255,255,0.4);">by <?= htmlspecialchars($topic->user_name ?? 'Unknown') ?> in <?= htmlspecialchars($topic->category_name ?? '') ?></small>
                </div>
                <?php endforeach; ?>
            <?php else: ?>
                <p style="color: rgba(255,255,255,0.5);">No recent topics</p>
            <?php endif; ?>
        </div>
    </div>
</div>
