<div class="container-fluid">

<h2 class="fw-bold mb-4">
Enterprise Audit & Activity Intelligence Center
</h2>

<div class="row g-3 mb-4">

<?php

$cards = [
    'Submission Activity' => $stats['submission_activity'],
    'Last 7 Days' => $stats['recent_submission_activity'],
    'Workflow Updates' => $stats['workflow_updates'],
    'Author Events' => $stats['author_events'],
    'Admin Events' => $stats['admin_events'],
];

foreach ($cards as $label => $value):

?>

<div class="col-md-2">
<div class="card border-0 shadow-sm">
<div class="card-body text-center">
<div class="text-muted">
<?= htmlspecialchars($label) ?>
</div>
<h3>
<?= (int)$value ?>
</h3>
</div>
</div>
</div>

<?php endforeach; ?>

</div>

<div class="card border-0 shadow-sm">

<div class="card-header fw-bold">
Recent Activity
</div>

<div class="table-responsive">

<table class="table table-striped align-middle">

<thead>
<tr>
<th>ID</th>
<th>Submission</th>
<th>Title</th>
<th>Actor</th>
<th>Role</th>
<th>Event</th>
<th>Title</th>
<th>Date</th>
</tr>
</thead>

<tbody>

<?php foreach ($rows as $r): ?>

<tr>
<td><?= (int)$r['id'] ?></td>
<td><?= htmlspecialchars($r['submission_no'] ?? '') ?></td>
<td><?= htmlspecialchars($r['title'] ?? '') ?></td>
<td><?= (int)($r['actor_id'] ?? 0) ?></td>
<td><?= htmlspecialchars($r['actor_role'] ?? '') ?></td>
<td><?= htmlspecialchars($r['event_key'] ?? '') ?></td>
<td><?= htmlspecialchars($r['event_title'] ?? '') ?></td>
<td><?= htmlspecialchars($r['created_at'] ?? '') ?></td>
</tr>

<?php endforeach; ?>

</tbody>

</table>

</div>

</div>

</div>
