<?php
require_once __DIR__ . '/../../admin/_nav.php';
$pageTitle  = 'Attendance';
$sidebarNav = adminNav();
$u = fn($p) => \Core\View::url($p);
?>
<div class="page-header">
  <div><h1>Attendance</h1><p><?= date('l, d F Y', strtotime($date)) ?></p></div>
  <form method="GET" style="display:flex;gap:8px">
    <input type="date" name="date" value="<?= htmlspecialchars($date) ?>" style="width:160px">
    <button type="submit" class="btn btn-secondary btn-sm">Go</button>
  </form>
</div>

<div class="grid g4" style="margin-bottom:24px">
  <div class="stat-card"><div class="stat-icon si-green"><i class="bi bi-check-circle"></i></div><div class="stat-info"><h3><?= $summary['present'] ?></h3><p>Present</p></div></div>
  <div class="stat-card"><div class="stat-icon si-red"><i class="bi bi-x-circle"></i></div><div class="stat-info"><h3><?= $summary['absent'] ?></h3><p>Absent</p></div></div>
  <div class="stat-card"><div class="stat-icon si-amber"><i class="bi bi-clock"></i></div><div class="stat-info"><h3><?= $summary['late'] ?></h3><p>Late</p></div></div>
  <div class="stat-card"><div class="stat-icon si-blue"><i class="bi bi-shield-check"></i></div><div class="stat-info"><h3><?= $summary['excused'] ?></h3><p>Excused</p></div></div>
</div>

<div class="card">
  <div class="card-header"><h5>Take Attendance by Stream</h5></div>
  <div class="card-body">
    <div class="grid g3">
      <?php foreach($streams as $s): ?>
      <a href="<?= $u('admin/attendance/'.$s['id'].'/take?date='.$date) ?>" class="stat-card" style="text-decoration:none;cursor:pointer;transition:box-shadow .2s" onmouseover="this.style.boxShadow='0 4px 20px rgba(0,0,0,.1)'" onmouseout="this.style.boxShadow='none'">
        <div class="stat-icon si-green"><i class="bi bi-people"></i></div>
        <div class="stat-info"><h3 style="font-size:15px"><?= htmlspecialchars($s['full_name']) ?></h3><p>Take Attendance</p></div>
        <i class="bi bi-chevron-right" style="color:var(--gray);margin-left:auto"></i>
      </a>
      <?php endforeach; ?>
    </div>
  </div>
</div>
