<?php
require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/includes/db.php';
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/functions_tags.php';
require_once __DIR__ . '/includes/layout.php';

$tagId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
$tag = tagInfo($tagId);
if (!$tag) {
    renderHeader('태그 없음', 'tags');
    echo '<div class="alert-box alert-danger"><div class="alert-content"><p>태그를 찾을 수 없습니다.</p></div></div>';
    echo '<a class="btn btn-secondary" href="tags.php">태그 목록</a>';
    renderFooter();
    exit;
}
$songs = songsByTag($tagId, 300);
renderHeader('#' . $tag['name'], 'tags');
?>
<div class="tag-detail-page">
    <div class="page-title-section">
        <h1 class="page-main-title">#<?php echo h($tag['name']); ?></h1>
        <p class="page-subtitle"><?php echo number_format(count($songs)); ?>곡을 표시합니다.</p>
    </div>
    <?php renderSongList($songs); ?>
</div>
<?php renderFooter(); ?>
