<div class="flex gap-2" style="margin-bottom:12px">
  <?php foreach ($distribution as $d) : ?><span class="badge badge-outline"><?= $d['rating'] ?>★ × <?= $d['c'] ?></span><?php endforeach; ?>
  <?php if (empty($distribution)) : ?><span class="text-faint text-sm">No CSAT responses yet.</span><?php endif; ?>
</div>
<?php \App\Core\View::render('reports/_toolbar', ['show' => ['date' => true, 'customer' => true, 'minRating' => true], 'filters' => $filters, 'query' => $query], null); ?>
<div class="card">
  <div class="table-wrap">
    <table class="table">
      <thead><tr><th>Ticket</th><th>Customer</th><th>Rating</th><th>Comment</th><th>Date</th></tr></thead>
      <tbody>
      <?php foreach ($rows as $r) : ?>
        <tr>
          <td class="mono"><?= e($r['ticket_no']) ?></td>
          <td><?= e($r['customer_name']) ?></td>
          <td><?= str_repeat('★', (int)$r['rating']) . str_repeat('☆', 5 - (int)$r['rating']) ?></td>
          <td class="text-sm"><?= e($r['comment']) ?></td>
          <td class="text-sm"><?= fmt_dt($r['created_at']) ?></td>
        </tr>
      <?php endforeach; ?>
      <?php if (empty($rows)) : ?><tr><td colspan="5" class="text-faint">No CSAT responses yet.</td></tr><?php endif; ?>
      </tbody>
    </table>
  </div>
</div>
