<?php
$title='Chair Capacity Planner';
?>

<div class="container-fluid py-4">

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

<h2>
Chair Capacity Planner
</h2>

<p class="text-muted">
Track-chair workload, review ownership, governance balance and recovery readiness.
</p>

</div>
</div>

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

<div class="col-md-3">
<div class="card border-0 shadow-sm">
<div class="card-body text-center">
<div class="text-muted">Total Chairs</div>
<h1 class="text-primary">
<?= (int)$summary['total_chairs'] ?>
</h1>
</div>
</div>
</div>

<div class="col-md-3">
<div class="card border-0 shadow-sm">
<div class="card-body text-center">
<div class="text-muted">Critical Capacity</div>
<h1 class="text-danger">
<?= (int)$summary['critical'] ?>
</h1>
</div>
</div>
</div>

<div class="col-md-3">
<div class="card border-0 shadow-sm">
<div class="card-body text-center">
<div class="text-muted">High Capacity</div>
<h1 class="text-warning">
<?= (int)$summary['high'] ?>
</h1>
</div>
</div>
</div>

<div class="col-md-3">
<div class="card border-0 shadow-sm">
<div class="card-body text-center">
<div class="text-muted">Idle Chairs</div>
<h1 class="text-success">
<?= (int)$summary['idle'] ?>
</h1>
</div>
</div>
</div>

</div>

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

<h4>Chair Governance Capacity Matrix</h4>

<div class="table-responsive">

<table class="table table-bordered table-hover">

<thead class="table-dark">

<tr>
<th>User</th>
<th>Tracks</th>
<th>Submissions</th>
<th>Reviews</th>
<th>Completed</th>
<th>Open</th>
<th>Overdue</th>
<th>Capacity</th>
</tr>

</thead>

<tbody>

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

<tr>

<td><?= htmlspecialchars($r['chair_name']) ?></td>

<td><?= (int)$r['tracks_owned'] ?></td>

<td><?= (int)$r['submissions'] ?></td>

<td><?= (int)$r['reviews'] ?></td>

<td><?= (int)$r['completed_reviews'] ?></td>

<td><?= (int)$r['open_reviews'] ?></td>

<td><?= (int)$r['overdue_reviews'] ?></td>

<td>

<?php if($r['capacity']=='CRITICAL'): ?>

<span class="badge bg-danger">
CRITICAL
</span>

<?php elseif($r['capacity']=='HIGH'): ?>

<span class="badge bg-warning text-dark">
HIGH
</span>

<?php elseif($r['capacity']=='NORMAL'): ?>

<span class="badge bg-info">
NORMAL
</span>

<?php else: ?>

<span class="badge bg-success">
LOW
</span>

<?php endif; ?>

</td>

</tr>

<?php endforeach; ?>

</tbody>

</table>

</div>

</div>
</div>

</div>
