<?php
$title='Governance Load Balancer';
?>

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

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

<h2>
Governance Load Balancer
</h2>

<p class="text-muted">
Identify overloaded governance owners and recommend balancing actions.
</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">Overloaded Chairs</div>
<h1 class="text-danger">
<?= (int)$summary['overloaded'] ?>
</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">Balanced Chairs</div>
<h1 class="text-success">
<?= (int)$summary['balanced'] ?>
</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-warning">
<?= (int)$summary['idle'] ?>
</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">Governance Owners</div>
<h1 class="text-primary">
<?= count($rows) ?>
</h1>
</div>
</div>
</div>

</div>

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

<div class="card-body">

<h4>
Governance Balancing Matrix
</h4>

<div class="table-responsive">

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

<thead class="table-dark">

<tr>
<th>Chair</th>
<th>Tracks</th>
<th>Reviews</th>
<th>Status</th>
<th>Suggested Action</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['reviews'] ?></td>

<td>

<?php if($r['balance_status']=='OVERLOADED'): ?>

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

<?php elseif($r['balance_status']=='IDLE'): ?>

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

<?php else: ?>

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

<?php endif; ?>

</td>

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

</tr>

<?php endforeach; ?>

</tbody>

</table>

</div>

</div>

</div>

</div>
