<?php require_once __DIR__ . '/config.php'; $settings = get_settings(); ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title><?= esc($settings['event_name'] ?? ($settings['site_name'] ?? 'Broadcasturself')) ?></title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="site-shell">
  <div class="topbar">
    <div class="brand">
      <img src="<?= esc($settings['site_logo'] ?? 'assets/site-logo.png') ?>" alt="Logo">
      <div>
        <h1><?= esc($settings['site_name'] ?? 'Broadcasturself') ?></h1>
        <div class="meta"><?= esc($settings['site_tagline'] ?? 'Live radio event network') ?></div>
      </div>
    </div>
    <div class="live-pill"><span class="live-dot"></span><span><?= strtoupper(esc($settings['site_status'] ?? 'live')) ?></span></div>
  </div>
  <div class="nav">
    <a href="index.php">Home</a>
    <a href="stations.php">Participating Stations</a>
    <a href="schedule.php">Schedule</a>
    <a href="submit.php">Submit Entry</a>
    <a href="poll.php">Live Polls</a>
  </div>
    <?php
    $rows = get_schedule();
    $grouped = [];
    foreach ($rows as $row) {
      $day = $row['day_label'] ?? ($row['day_key'] ?? 'Schedule');
      $grouped[$day][] = $row;
    }
    ?>
    <div class="hero">
      <h2><?= esc($settings['schedule_title'] ?? 'Event Schedule') ?></h2>
      <p><?= esc($settings['schedule_intro'] ?? '') ?></p>
    </div>
    <?php if (empty($grouped)): ?>
      <div class="card"><p>No schedule entries have been added yet.</p></div>
    <?php else: ?>
      <?php foreach ($grouped as $day => $items): ?>
        <div class="card schedule-day">
          <h3><?= esc($day) ?></h3>
          <?php foreach ($items as $item): ?>
            <div class="schedule-row">
              <div><strong><?= esc($item['time_label'] ?? '') ?></strong></div>
              <div><?= esc($item['title'] ?? '') ?></div>
              <div><?= esc(trim(($item['station'] ?? '') . (!empty($item['note']) ? ' — ' . $item['note'] : ''))) ?></div>
            </div>
          <?php endforeach; ?>
        </div>
      <?php endforeach; ?>
    <?php endif; ?>

  <div class="footer-note"><?= esc($settings['footer_note'] ?? 'Powered by Broadcasturself') ?></div>
</div>
</body>
</html>
