<?php
require_once __DIR__ . '/stream_lib.php';
@smurf_chart_log_play(__DIR__ . '/../data/chart_plays.log', __DIR__ . '/../data/top50_state.json');
$__htr_settings = [];
$__htr_settings_file = __DIR__ . '/../data/settings.json';
if (is_file($__htr_settings_file)) {
  $__htr_raw = json_decode((string)file_get_contents($__htr_settings_file), true);
  if (is_array($__htr_raw)) $__htr_settings = $__htr_raw;
}
$__show_events_nav = array_key_exists('events_show_in_nav', $__htr_settings) ? !empty($__htr_settings['events_show_in_nav']) : true;
$__show_charts_nav = array_key_exists('top50_show_in_nav', $__htr_settings) ? !empty($__htr_settings['top50_show_in_nav']) : true;
$__show_player_nav = !empty($__htr_settings['player_show_in_nav']);
$__current = basename(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/');
if ($__current === '') $__current = 'index.php';
function ugfx_nav_active(string $file, string $current): string { return $file === $current ? ' active' : ''; }
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><?= htmlspecialchars($pageTitle ?? 'Underground FX Radio', ENT_QUOTES, 'UTF-8') ?></title>
  <meta name="description" content="Underground FX Radio — a bold, high-energy community radio experience with live DJs, requests, chat, schedules, news, events and charts.">
  <meta property="og:type" content="website">
  <meta property="og:site_name" content="Underground FX Radio">
  <meta property="og:image" content="/assets/images/ugfx-hero.png">
  <meta property="og:title" content="Underground FX Radio">
  <meta property="og:description" content="Turn it up. Join the live stream, meet the DJs, send requests and experience the new Underground FX sound.">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:image" content="/assets/images/ugfx-hero.png">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
  <link rel="stylesheet" href="/assets/css/theme-ugfx.css">
  <?php if (!empty($pageClass) && strpos((string)$pageClass, 'page-admin') !== false): ?>
  <link rel="stylesheet" href="/admin/assets/admin-v2.css">
  <?php endif; ?>
</head>
<body class="<?= htmlspecialchars($pageClass ?? '', ENT_QUOTES, 'UTF-8') ?>">
<nav class="navbar navbar-expand-xl navbar-dark ugfx-navbar">
  <div class="container ugfx-nav-shell">
    <div class="ugfx-nav-top">
      <a class="navbar-brand ugfx-brand" href="/">
        <span class="ugfx-brand-mark-wrap">
          <img src="/assets/images/ugfx-hero.png" alt="Underground FX Radio" class="ugfx-brand-mark">
        </span>
        <span class="ugfx-brand-copy">
          <span class="ugfx-brand-topline">Underground FX</span>
          <span class="ugfx-brand-bottomline">Turn it up. Join the underground.</span>
        </span>
      </a>

      <div class="ugfx-desktop-actions d-none d-xl-flex">
        <div class="ugfx-live-pill"><span class="dot"></span>Live now</div>
        <a class="ugfx-quick-action" href="/requests.php"><i class="bi bi-music-note-list"></i><span>Request</span></a>
        <a class="ugfx-quick-action" href="https://discord.gg/hA2uWMpCT8" target="_blank" rel="noopener"><i class="bi bi-discord"></i><span>Discord</span></a>
        <a class="ugfx-quick-action ugfx-admin-quick" href="/admin.php"><i class="bi bi-shield-lock"></i><span>Admin</span></a>
      </div>

      <button class="navbar-toggler ugfx-nav-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
    </div>

    <div class="collapse navbar-collapse" id="navbarNav">
      <div class="ugfx-nav-bottom">
        <ul class="navbar-nav ugfx-nav-list">
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('index.php', $__current) ?>" href="/"><i class="bi bi-house-door"></i><span>Home</span></a></li>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('about.php', $__current) ?>" href="/about.php"><i class="bi bi-broadcast-pin"></i><span>About</span></a></li>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('djs.php', $__current) ?>" href="/djs.php"><i class="bi bi-mic"></i><span>DJs</span></a></li>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('schedule.php', $__current) ?>" href="/schedule.php"><i class="bi bi-calendar3"></i><span>Schedule</span></a></li>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('requests.php', $__current) ?>" href="/requests.php"><i class="bi bi-music-note-list"></i><span>Requests</span></a></li>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('news.php', $__current) ?>" href="/news.php"><i class="bi bi-newspaper"></i><span>News</span></a></li>
          <?php if ($__show_events_nav): ?><li class="nav-item"><a class="nav-link<?= ugfx_nav_active('events.php', $__current) ?>" href="/events.php"><i class="bi bi-stars"></i><span>Events</span></a></li><?php endif; ?>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('friends.php', $__current) ?>" href="/friends.php"><i class="bi bi-people"></i><span>Friends</span></a></li>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('fans.php', $__current) ?>" href="/fans.php"><i class="bi bi-hearts"></i><span>Fans</span></a></li>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('team.php', $__current) ?>" href="/team.php"><i class="bi bi-person-plus"></i><span>Join Us</span></a></li>
          <?php if ($__show_charts_nav): ?><li class="nav-item"><a class="nav-link<?= ugfx_nav_active('top50.php', $__current) ?>" href="/top50.php"><i class="bi bi-graph-up-arrow"></i><span>Charts</span></a></li><?php endif; ?>
          <li class="nav-item"><a class="nav-link<?= ugfx_nav_active('chat.php', $__current) ?>" href="/chat.php"><i class="bi bi-chat-dots"></i><span>Chat</span></a></li>
          <?php if ($__show_player_nav): ?><li class="nav-item"><a class="nav-link" href="/popout-player.php" target="_blank" rel="noopener"><i class="bi bi-play-circle"></i><span>Player</span></a></li><?php endif; ?>
          <li class="nav-item d-xl-none"><a class="nav-link" href="/admin.php"><i class="bi bi-shield-lock"></i><span>Admin</span></a></li>
        </ul>
      </div>
    </div>
  </div>
  <div class="ugfx-nav-divider"></div>
  <div class="ugfx-nav-divider ugfx-nav-divider-secondary"></div>
</nav>
