<?php
require_once __DIR__.'/../includes/functions.php';
$admin = require_admin();
$adminTitle = 'Admin Module Center';
$adminSubtitle = 'Clean grouped control center for every admin module, shortcut and daily workflow.';
if (function_exists('mj_v289_ensure_schema')) { mj_v289_ensure_schema(); }
$groups = function_exists('mj_v289_admin_module_groups') ? mj_v289_admin_module_groups() : [];
$metrics = function_exists('mj_v289_admin_dashboard_metrics') ? mj_v289_admin_dashboard_metrics() : [];
include __DIR__.'/_header.php';
?>

<div class="row mb-3">
  <div class="col-lg-3 col-md-6 mb-3"><a class="mj-module-top" href="approval-center.php"><i class="fas fa-tasks"></i><div><b><?= e(number_format((int)(($metrics['listings_pending']??0)+($metrics['companies_pending']??0)+($metrics['payments_pending']??0)))) ?></b><span>Pending approvals</span></div></a></div>
  <div class="col-lg-3 col-md-6 mb-3"><a class="mj-module-top" href="payment-center.php?tab=review"><i class="fas fa-receipt"></i><div><b><?= e(number_format((int)($metrics['payments_pending']??0))) ?></b><span>Payment proofs</span></div></a></div>
  <div class="col-lg-3 col-md-6 mb-3"><a class="mj-module-top" href="support.php"><i class="fas fa-headset"></i><div><b><?= e(number_format((int)($metrics['support_open']??0))) ?></b><span>Open support</span></div></a></div>
  <div class="col-lg-3 col-md-6 mb-3"><a class="mj-module-top" href="system-health.php"><i class="fas fa-heartbeat"></i><div><b><?= e(function_exists('mj_v289_admin_health_score') ? mj_v289_admin_health_score($metrics) : 100) ?>%</b><span>System health</span></div></a></div>
</div>

<div class="row">
<?php foreach($groups as $key=>$group): ?>
  <div class="col-xl-6 mb-4" id="<?= e($key) ?>">
    <div class="card mj-module-center-card" style="--module-color:<?= e($group['color']) ?>">
      <div class="card-header">
        <div class="d-flex align-items-center">
          <span class="mj-module-icon"><i class="<?= e($group['icon']) ?>"></i></span>
          <div><h3 class="card-title mb-0"><?= e($group['title']) ?></h3><small class="text-muted"><?= e($group['desc']) ?></small></div>
        </div>
      </div>
      <div class="card-body">
        <div class="row">
          <?php foreach($group['links'] as $link): ?>
          <div class="col-sm-6 mb-2">
            <a href="<?= e($link[1]) ?>" class="mj-module-link"><i class="<?= e($link[2]) ?>"></i><span><?= e($link[0]) ?></span></a>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
    </div>
  </div>
<?php endforeach; ?>
</div>

<div class="card card-outline card-primary">
  <div class="card-header"><h3 class="card-title"><i class="fas fa-puzzle-piece mr-2"></i>Enable / Disable Site Modules</h3></div>
  <div class="card-body">
    <p class="text-muted">Use this when you want to hide a whole feature from users. Per-user controls remain in <b>Admin → Users → Access</b>.</p>
    <a href="modules.php" class="btn btn-primary"><i class="fas fa-sliders-h mr-1"></i>Open Module Settings</a>
    <a href="users.php" class="btn btn-outline-secondary"><i class="fas fa-user-lock mr-1"></i>User Access Controls</a>
  </div>
</div>

<?php include __DIR__.'/_footer.php'; ?>
