<div class="container-fluid">

<h2 class="mb-4">
Reviewer Analytics Dashboard
</h2>

<div class="row mb-4">

<div class="col-md-3">
<div class="card p-3">
<h6>Total Reviewers</h6>
<h2><?= count($leaderboard) ?></h2>
</div>
</div>

<div class="col-md-3">
<div class="card p-3">
<h6>Top Reviewer Score</h6>
<h2>
<?= number_format(
(float)($leaderboard[0]['final_score'] ?? 0),
1
) ?>
</h2>
</div>
</div>

<div class="col-md-3">
<div class="card p-3">
<h6>Overloaded Reviewers</h6>
<h2><?= count($overloaded) ?></h2>
</div>
</div>

</div>

<div class="card p-3 mb-4">

<h4>
Reviewer Leaderboard
</h4>

<table class="table table-striped">

<tr>
<th>Reviewer</th>
<th>Score</th>
<th>Completion %</th>
<th>Acceptance %</th>
<th>Quality</th>
</tr>

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

<tr>

<td>
<?= htmlspecialchars(
trim(
($r['first_name'] ?? '')
.' '.
($r['last_name'] ?? '')
)
) ?>
<br>
<small>
<?= htmlspecialchars(
$r['email'] ?? ''
) ?>
</small>
</td>

<td>
<?= number_format(
(float)$r['final_score'],
2
) ?>
</td>

<td>
<?= number_format(
(float)$r['completion_rate'],
2
) ?>
</td>

<td>
<?= number_format(
(float)$r['acceptance_rate'],
2
) ?>
</td>

<td>
<?= number_format(
(float)$r['quality_score'],
2
) ?>
</td>

</tr>

<?php endforeach; ?>

</table>

</div>

<div class="card p-3">

<h4>
Overloaded Reviewers
</h4>

<table class="table table-bordered">

<tr>
<th>Reviewer ID</th>
<th>Active Reviews</th>
</tr>

<?php foreach($overloaded as $o): ?>

<tr>

<td><?= (int)$o['reviewer_id'] ?></td>

<td><?= (int)$o['active_reviews'] ?></td>

</tr>

<?php endforeach; ?>

</table>

</div>

</div>
