<?php $pageTitle = 'Laboratories'; include __DIR__ . '/../shared/header.php'; ?>

<div class="page-header">
  <div>
    <div class="page-title"><i class="bi bi-building me-2"></i>Laboratories</div>
    <div class="page-subtitle">Manage the nine metrology laboratories</div>
  </div>
  <a href="<?= APP_URL ?>/index.php?page=labs&action=create" class="btn btn-primary">
    <i class="bi bi-plus-circle me-1"></i>Add Laboratory
  </a>
</div>

<div class="row g-3">
<?php foreach ($labs as $l): ?>
  <div class="col-md-6 col-xl-4">
    <div class="card h-100">
      <div class="card-body">
        <div class="d-flex align-items-start justify-content-between mb-2">
          <span class="badge bg-primary fs-6"><?= e($l['lab_code']) ?></span>
          <a href="<?= APP_URL ?>/index.php?page=labs&action=edit&id=<?= $l['lab_id'] ?>" class="btn btn-sm btn-outline-secondary"><i class="bi bi-pencil"></i></a>
        </div>
        <h6 class="fw-bold text-primary mb-1"><?= e($l['lab_name']) ?></h6>
        <div class="text-muted small mb-3"><?= e($l['department']) ?></div>
        <div class="d-flex gap-3">
          <div class="text-center">
            <div class="fw-bold"><?= $l['officer_count'] ?></div>
            <div class="text-muted" style="font-size:11px;">Officers</div>
          </div>
          <div class="text-center">
            <div class="fw-bold"><?= $l['request_count'] ?></div>
            <div class="text-muted" style="font-size:11px;">Requests</div>
          </div>
        </div>
      </div>
    </div>
  </div>
<?php endforeach; ?>
</div>

<?php include __DIR__ . '/../shared/footer.php'; ?>
