<?php
/**
 * 话题卡片组件
 * 
 * @param array $topic 话题数据
 * @param string $size 尺寸: small|medium|large
 */

$name = $topic['name'] ?? $topic['keyword'] ?? '';
$postCount = $topic['post_count'] ?? 0;
$description = $topic['description'] ?? '';
$icon = $topic['icon'] ?? '';
$size = $size ?? 'medium';
?>
<div class="topic-card <?php echo "topic-card-{$size}"; ?>" 
     onclick="window.location.href='<?php echo Helper::getBaseUrl(); ?>/?r=mobile/topic&keyword=<?php echo urlencode($name); ?>'">
    <?php if ($icon): ?>
    <div class="topic-card-icon">
        <img src="<?php echo Helper::uploadUrl($icon); ?>" alt="">
    </div>
    <?php else: ?>
    <div class="topic-card-icon">
        <span class="iconify" data-icon="mdi:tag"></span>
    </div>
    <?php endif; ?>
    <div class="topic-card-content">
        <div class="topic-card-name"><?php echo htmlspecialchars($name); ?></div>
        <div class="topic-card-count"><?php echo number_format($postCount); ?> 帖子</div>
        <?php if ($description && $size !== 'small'): ?>
        <div class="topic-card-desc"><?php echo htmlspecialchars($description); ?></div>
        <?php endif; ?>
    </div>
</div>
