<?php $miniNowPlaying = ugfx_now_playing(); ?>
<div class="ugfx-playerbar">
    <div class="container-xxl">
        <div class="ugfx-playerbar-inner">
            <div class="d-flex align-items-center gap-3 min-w-0">
                <img src="<?= htmlspecialchars($miniNowPlaying['art']) ?>" alt="cover" class="ugfx-player-thumb">
                <div class="min-w-0">
                    <div class="ugfx-micro-label">NOW PLAYING</div>
                    <div class="ugfx-player-title text-truncate current-track"><?= htmlspecialchars($miniNowPlaying['title']) ?></div>
                    <div class="ugfx-player-meta text-truncate"><span class="listener-count"><?= (int) ($miniNowPlaying['listeners'] ?? 0) ?></span> listener<?= ((int)($miniNowPlaying['listeners'] ?? 0) === 1 ? '' : 's') ?> · <span class="current-artist"><?= htmlspecialchars($miniNowPlaying['display_show'] ?? $miniNowPlaying['artist']) ?></span></div>
                </div>
            </div>
            <div class="d-flex align-items-center gap-2">
                <a class="btn ugfx-btn-outline btn-sm" href="player-popup.php" target="_blank" rel="noopener"><i class="bi bi-box-arrow-up-right"></i></a>
                <a class="btn ugfx-btn-outline btn-sm" href="<?= htmlspecialchars($miniNowPlaying['direct_stream_url'] ?: ($ugfx['stream_url'] ?? '')) ?>" target="_blank" rel="noopener" data-direct-stream><i class="bi bi-broadcast"></i></a>
                <button class="btn ugfx-btn-primary btn-sm" data-stream-url="<?= htmlspecialchars($miniNowPlaying['stream_url'] ?: ($ugfx['stream_url'] ?? '')) ?>" data-player-toggle>
                    <i class="bi bi-play-fill"></i> Play Live
                </button>
                <audio id="ugfxAudio" preload="none" src="<?= htmlspecialchars($miniNowPlaying['stream_url'] ?: ($ugfx['stream_url'] ?? '')) ?>"></audio>
            </div>
        </div>
    </div>
</div>
