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

$definitions = getAutoPlaylistDefinitions();
$playlistIcons = [
    'recent_top' => 'fa-clock-rotate-left',
    'monthly_top' => 'fa-calendar-days',
    'top_rated' => 'fa-star',
    'liked' => 'fa-heart',
    'old_liked' => 'fa-rotate-left',
    'recent_added' => 'fa-sparkles',
    'never_played' => 'fa-circle-question',
    'unrated_popular' => 'fa-fire',
    'tag_mix' => 'fa-tags',
    'time_context' => 'fa-sun',
    'hidden_gems' => 'fa-gem',
    'random_mix' => 'fa-shuffle',
];

renderHeader('자동 플레이리스트', 'auto_playlists');
?>
<div class="auto-playlists-page">
    <div class="auto-playlist-hero">
        <div class="auto-playlist-hero-copy">
            <span class="auto-playlist-kicker">자동 믹스</span>
            <h1 class="page-main-title">자동 플레이리스트</h1>
            <p class="page-subtitle">보관함 데이터, 청취 기록, 좋아요, 별점을 기준으로 바로 들을 수 있는 믹스를 구성합니다.</p>
        </div>
        <div class="auto-playlist-hero-meta" aria-label="자동 플레이리스트 요약">
            <span><strong><?php echo number_format(count($definitions)); ?></strong>개 믹스</span>
            <span>실시간 구성</span>
        </div>
    </div>

    <div class="auto-playlist-grid">
        <?php foreach ($definitions as $type => $definition): ?>
            <?php
            $count = count(getAutoPlaylistSongs($type, 12));
            $icon = $playlistIcons[$type] ?? 'fa-wand-magic-sparkles';
            ?>
            <a class="auto-playlist-card" href="auto_playlist.php?type=<?php echo h($type); ?>">
                <span class="auto-playlist-card-icon"><i class="fas <?php echo h($icon); ?>"></i></span>
                <span class="auto-playlist-card-copy">
                    <strong><?php echo h($definition['title']); ?></strong>
                    <span><?php echo h($definition['description']); ?></span>
                </span>
                <span class="auto-playlist-card-footer">
                    <small><?php echo number_format($count); ?>곡 미리보기</small>
                    <em>열기 <i class="fa-solid fa-arrow-right"></i></em>
                </span>
            </a>
        <?php endforeach; ?>
    </div>
</div>
<?php renderFooter(); ?>
