<?php
if (!ob_get_level()) ob_start();
if (!isset($_SESSION)) session_start();
require __DIR__ . '/../auth.php';
require_once __DIR__ . '/admin_lib.php';
$pageTitle = $pageTitle ?? 'Underground FX Admin Studio';
$pageClass = $pageClass ?? 'page-admin';
$settingsPath = __DIR__ . '/../../data/settings.json';
$settings = is_file($settingsPath) ? json_decode((string)file_get_contents($settingsPath), true) : [];
if (!is_array($settings)) $settings = [];
$streamUrl = trim((string)($settings['stream_url'] ?? 'http://radio.undergroundfxradio.com:9000/stream'));
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Orbitron:wght@500;700;800&display=swap" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/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">
  <link rel="stylesheet" href="/admin/assets/admin-v2.css">
</head>
<body class="page-admin">
<div class="admin-studio-shell">
  <aside class="admin-studio-sidebar">
    <a href="/admin/index.php" class="admin-brand"><span class="admin-brand-mark">UGFX</span><span><strong>Admin Studio</strong><small>Control room shell</small></span></a>
    <div class="admin-sidebar-group"><span>Core</span><a href="/admin/index.php">Dashboard</a><a href="/admin/news.php">News</a><a href="/admin/events.php">Events</a><a href="/admin/schedule.php">Schedule</a><a href="/admin/djs.php">DJs</a></div>
    <div class="admin-sidebar-group"><span>Community</span><a href="/admin/requests.php">Requests</a><a href="/admin/comments.php">Comments</a><a href="/admin/chat.php">Chat</a><a href="/admin/contact.php">Contact</a><a href="/admin/applications.php">Join the Team</a></div>
    <div class="admin-sidebar-group"><span>System</span><a href="/admin/navigation.php">Navigation</a><a href="/admin/player.php">Player</a><a href="/admin/radiostats.php">Radio Stats</a><a href="/admin/users.php">Users</a><a href="/admin/backup.php">Backup</a></div>
  </aside>
  <main class="admin-studio-main">
    <div class="admin-topbar">
      <div><div class="fx-section-kicker">Underground FX control room</div><h1><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h1></div>
      <div class="admin-top-actions"><a href="<?= htmlspecialchars($streamUrl, ENT_QUOTES, 'UTF-8') ?>" target="_blank" rel="noopener">Listen live</a><a href="/index.php">Main site</a><a href="/admin/logout.php">Logout</a></div>
    </div>
