<?php require_once __DIR__ . '/includes/bootstrap.php';
$pageTitle = 'Listen Live | Underground FX Radio';
$currentPage = basename(__FILE__);
include __DIR__ . '/includes/header.php';
?>
<section class="ugfx-page-hero">
  <div class="container-xxl">
    <div class="ugfx-kicker"><i class="bi bi-lightning-charge-fill"></i> Underground FX live studio</div>
    <h1 class="page-title">Listen live</h1>
    <p class="page-copy">Listen to Underground FX live with current track details and direct stream access.</p>
  </div>
</section>

<section class="section-pad pt-3">
  <div class="container-xxl">
    <?php $np = ugfx_now_playing(); $show = ugfx_current_show(); ?>
    <div class="ugfx-grid-2">
      <div class="ugfx-card p-4">
        <div class="row g-4 align-items-center">
          <div class="col-md-5"><img src="<?= htmlspecialchars($np['art']) ?>" alt="art" class="img-fluid rounded-4"></div>
          <div class="col-md-7">
            <div class="ugfx-micro-label">NOW PLAYING</div>
            <h2><?= htmlspecialchars($np['title']) ?></h2>
            <p class="text-secondary mb-2">Source: <span class="current-artist"><?= htmlspecialchars($np['artist']) ?></span> · Mount <?= htmlspecialchars($np['mount'] ?? '/autodj') ?></p>
            <div class="d-flex gap-2 flex-wrap mb-4">
              <span class="ugfx-chip"><i class="bi bi-broadcast"></i> <?= htmlspecialchars($np['status']) ?></span>
              <span class="ugfx-chip"><i class="bi bi-headphones"></i> <span class="listener-count"><?= (int) $np['listeners'] ?></span> listener connections</span>
              <span class="ugfx-chip"><i class="bi bi-calendar-event"></i> Next: <?= htmlspecialchars($show['next']) ?></span>
            </div>
            <div class="d-flex gap-2 flex-wrap">
              <button class="btn ugfx-btn-primary" data-player-toggle><i class="bi bi-play-fill"></i> Start Stream</button>
              <button class="btn ugfx-btn-outline" data-copy-stream="<?= htmlspecialchars($np['direct_stream_url'] ?? ($np['public_stream_url'] ?? ($ugfx['public_stream_url'] ?? $ugfx['stream_url']))) ?>">Copy Direct Link</button>
              <a class="btn ugfx-btn-outline" href="player-popup.php" target="_blank" rel="noopener">Popout Player</a>
            </div>
          </div>
        </div>
      </div>
      <div class="ugfx-card p-4">
        <div class="ugfx-micro-label">STREAM NOTES</div>
        <h3>Listen live</h3>
        <ul class="text-secondary mb-4">
          <li>Live stats are read from the active Icecast AutoDJ source.</li>
          <li>Listener totals and current track info update from Icecast 2.5.0.</li>
          <li>Direct stream links stay available across the site.</li>
          <li>Live DJ switching can be expanded from here when needed.</li>
        </ul>
        <div class="ugfx-card p-3">
          <div class="ugfx-micro-label">STREAM URL</div>
          <code class="text-warning"><?= htmlspecialchars($np['direct_stream_url'] ?? ($np['public_stream_url'] ?? ($ugfx['public_stream_url'] ?? $ugfx['stream_url']))) ?></code>
        </div>
      </div>
    </div>
  </div>
</section>

<?php include __DIR__ . '/includes/footer.php'; ?>
