
<?php
session_start();
$pageTitle = 'Dashboard — Oldies And More Radio';
include __DIR__ . '/includes/header.php';
$pages = admin_read_json(__DIR__ . '/../data/pages.json', []);
$fans = admin_read_json(__DIR__ . '/../data/fans.json', []);
$promo = admin_read_json(__DIR__ . '/../data/promo.json', []);
$settings = oldies_read_settings();
$comments = file_exists(__DIR__ . '/../data/comments.txt') ? file(__DIR__ . '/../data/comments.txt', FILE_IGNORE_NEW_LINES) : [];
$requests = file_exists(__DIR__ . '/../data/requests.txt') ? file(__DIR__ . '/../data/requests.txt', FILE_IGNORE_NEW_LINES) : [];
function dashCard($href,$emoji,$title,$desc,$foot='Open tool'){ echo '<a class="admin-card-link" href="'.admin_h($href).'"><div><div class="card-emoji">'.$emoji.'</div><div class="card-title">'.admin_h($title).'</div><div class="card-desc">'.admin_h($desc).'</div></div><div class="card-foot">'.admin_h($foot).' →</div></a>'; }
?>
<section class="admin-hero-grid">
  <section class="admin-card-panel">
    <h1 class="admin-title">Welcome back to Oldies And More</h1>
    <p class="admin-stat-meta">This merged dashboard keeps your existing Oldies content but adds the missing Smurfettes-style tools and pages.</p>
    <div class="admin-stat-grid">
      <div class="admin-stat-card"><h3>Custom Pages</h3><div class="admin-stat-value"><?= is_array($pages) ? count($pages) : 0 ?></div><div class="admin-stat-meta">Extra landing pages you can publish in navigation.</div></div>
      <div class="admin-stat-card"><h3>Fans</h3><div class="admin-stat-value"><?= is_array($fans) ? count($fans) : 0 ?></div><div class="admin-stat-meta">Supporter cards and top-fan highlights.</div></div>
      <div class="admin-stat-card"><h3>Comments</h3><div class="admin-stat-value"><?= count($comments) ?></div><div class="admin-stat-meta">Homepage comments waiting for moderation.</div></div>
      <div class="admin-stat-card"><h3>Requests</h3><div class="admin-stat-value"><?= count($requests) ?></div><div class="admin-stat-meta">Listener song requests collected on-site.</div></div>
    </div>
  </section>
  <section class="admin-card-panel">
    <h3>Feature snapshot</h3>
    <table class="admin-table"><tbody>
      <tr><td>Events page in navigation</td><td><?= !empty($settings['events_show_in_nav']) ? 'Shown' : 'Hidden' ?></td></tr>
      <tr><td>Fans page in navigation</td><td><?= !empty($settings['fans_show_in_nav']) ? 'Shown' : 'Hidden' ?></td></tr>
      <tr><td>Popout player link</td><td><?= !empty($settings['player_show_in_nav']) ? 'Shown' : 'Hidden' ?></td></tr>
      <tr><td>Live chat</td><td><?= !empty($settings['chat_enabled']) ? 'Enabled' : 'Disabled' ?></td></tr>
      <tr><td>Promotion active</td><td><?= !empty($promo['enabled']) ? 'Yes' : 'No' ?></td></tr>
    </tbody></table>
  </section>
</section>
<section class="content-card mt-3"><h2 class="admin-title">Content Studio</h2><div class="admin-grid-v2">
<?php dashCard('/admin/pages.php','🧩','Page Builder','Create extra custom pages while keeping the original Oldies pages untouched.'); ?>
<?php dashCard('/admin/news.php','📰','News','Manage station news items and featured stories.'); ?>
<?php dashCard('/admin/events.php','🎉','Events','Create promos, countdowns and listener entry forms.'); ?>
<?php dashCard('/admin/top50.php','🎵','Top 50','Control chart visibility and review current track history.'); ?>
<?php dashCard('/admin/schedule.php','📅','Schedule','Update daily shows and live DJ slots.'); ?>
<?php dashCard('/admin/about.php','ℹ️','About','Edit the station bio and story.'); ?>
<?php dashCard('/admin/media.php','🖼️','Media Library','Upload artwork and copy ready-to-use web paths.'); ?>
<?php dashCard('/admin/navigation.php','🧭','Navigation','Add extra links and toggle merged pages in navigation.'); ?>
</div></section>
<section class="content-card mt-3"><h2 class="admin-title">Community & Radio Tools</h2><div class="admin-grid-v2">
<?php dashCard('/admin/djs.php','🎙️','DJs','Manage presenter profiles and images.'); ?>
<?php dashCard('/admin/friends.php','🤝','Friends','Maintain partner and sponsor cards.'); ?>
<?php dashCard('/admin/fans.php','⭐','Fans','Showcase station supporters and top fans.'); ?>
<?php dashCard('/admin/contact.php','📨','Contact Messages','Review public contact form messages.'); ?>
<?php dashCard('/admin/applications.php','📝','Join the Team','Review presenter and volunteer applications.'); ?>
<?php dashCard('/admin/requests.php','🎶','Requests','Track listener requests and shoutouts.'); ?>
<?php dashCard('/admin/comments.php','💬','Comments','Approve, delete and moderate homepage discussion.'); ?>
<?php dashCard('/admin/chat.php','🗨️','Live Chat','Moderate the room and post as station staff.'); ?>
<?php dashCard('/admin/player.php','🪟','Popout Player','Control the popout player intro and stream link.'); ?>
<?php dashCard('/admin/radiostats.php','📡','Radio Stats','Check live Icecast information.'); ?>
</div></section>
<section class="content-card mt-3"><h2 class="admin-title">System & Safety</h2><div class="admin-grid-v2">
<?php if (($_SESSION['role'] ?? '') === 'admin') dashCard('/admin/users.php','👤','User Management','Manage admin and view-only users.'); ?>
<?php if (($_SESSION['role'] ?? '') === 'admin') dashCard('/admin/backup.php','🧰','Backup / Restore','Create a quick zip backup of site data folders.'); ?>
<?php dashCard('/admin/poll.php','📊','Poll Manager','Adjust the homepage poll and votes.'); ?>
<?php dashCard('/admin/westats.php','📈','Web Stats','Review Cloudflare and local traffic reporting.'); ?>
<?php if (($_SESSION['role'] ?? '') === 'admin') dashCard('http://cr3.broadcasturself.com:23990/','📻','Backup Icecast','Open backup source tools in a new tab.','Open external'); ?>
</div></section>
<?php include __DIR__ . '/includes/footer.php'; ?>
