<?php
require_once __DIR__ . '/lib/functions.php';
mdw_require_login();
global $mdw_downloads_file, $mdw_projects_file, $mdw_clients_file;
$downloads = mdw_read_json($mdw_downloads_file, []);
$projects = mdw_read_json($mdw_projects_file, []);
$documents = mdw_saved_documents();
$clients = mdw_read_json($mdw_clients_file ?? mdw_data_file('clients.json'), []);
mdw_render_header('Dashboard');
?>
<div class="grid">
  <section class="card"><h2>Downloads</h2><p class="muted">Manage public manuals, PDFs, patches, and resources.</p><p><strong><?php echo count($downloads); ?></strong> entries</p><a class="button" href="downloads.php">Manage Downloads</a></section>
  <section class="card"><h2>Project Showcase</h2><p class="muted">Manage public project cards, statuses, and display order.</p><p><strong><?php echo count($projects); ?></strong> projects</p><a class="button" href="projects.php">Manage Projects</a></section>
  <section class="card"><h2>Documents</h2><p class="muted">Create branded pricing sheets, project forms, contracts, and client documents.</p><p><strong><?php echo count($documents); ?></strong> saved docs</p><a class="button" href="documents.php">Manage Documents</a></section>
  <section class="card"><h2>Clients</h2><p class="muted">Track client names, contact details, hosting notes, and related work.</p><p><strong><?php echo count($clients); ?></strong> clients</p><a class="button" href="clients.php">Manage Clients</a></section>
  <section class="card"><h2>Backups</h2><p class="muted">Download a backup of admin data, documents, and uploads.</p><a class="button" href="backup.php">Open Backups</a></section>
  <section class="card"><h2>Site Updater</h2><p class="muted">Upload a ZIP patch and apply it directly to the site after a dry run.</p><a class="button" href="updater.php">Open Updater</a></section>
</div>
<section class="panel" style="margin-top:20px"><h2>Safe Architecture</h2><p>This admin area is separate from Ecommerce Templates. ECT stays in <code>vsadmin</code>. MDW Admin manages public content and MDW site updates around it.</p></section>
<?php mdw_render_footer(); ?>
