<?php require_once __DIR__ . '/../config.php'; require_admin(); $settings = get_settings(); ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Admin Control Room</title>
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<div class="admin-shell">
  <aside class="admin-sidebar">
    <div class="brand">
      <img src="../assets/site-logo.png" alt="Logo">
      <div>
        <h2>Control Room</h2>
        <div class="meta">Broadcasturself Admin</div>
      </div>
    </div>
    <nav>
      <a href="index.php">Dashboard</a>
      <a href="site-control.php">Site Control</a>
      <a href="stations.php">Stations</a>
      <a href="schedule.php">Schedule</a>
      <a href="clues.php">Clues</a>
      <a href="answers.php">Answers</a>
      <a href="submissions.php">Submissions</a>
      <a href="dj-control.php">DJ Control</a>
      <a href="network.php">Network Sync</a>
      <a href="listeners.php">Listener Panel</a>
      <a href="poll.php">Poll Control</a>
      <a href="logout.php">Logout</a>
    </nav>
  </aside>
  <main class="admin-main">
    <?php require_once __DIR__ . '/../core/icecast.php'; $rows = get_now_playing_data(); ?>
    <div class="card">
      <h1>Listener Panel</h1>
      <div class="table-wrap">
        <table>
          <thead><tr><th>Station</th><th>Status</th><th>Now Playing</th><th>Listeners</th><th>Mount</th></tr></thead>
          <tbody>
          <?php foreach ($rows as $row): ?>
            <tr>
              <td><?= esc((string) ($row['station'] ?? '')) ?></td>
              <td><?= esc(strtoupper((string) ($row['status'] ?? 'offline'))) ?></td>
              <td><?= esc((string) ($row['title'] ?? '')) ?></td>
              <td><?= (int) ($row['listeners'] ?? 0) ?></td>
              <td><?= esc((string) ($row['mount'] ?? '')) ?></td>
            </tr>
          <?php endforeach; ?>
          </tbody>
        </table>
      </div>
      <?php if (empty($rows)): ?><p class="meta">Add valid Icecast admin credentials to secure-config/streams.php to populate this panel.</p><?php endif; ?>
    </div>

  </main>
</div>
</body>
</html>
