<?php require __DIR__ . '/../../layouts/header.php'; $lang=current_lang(); ?>
<?php
$t=fn($ar,$en)=>($lang==='ar'?$ar:$en);
$confs=$confs??[]; $confId=(int)($confId??0); $rows=$rows??[];
?>
<div class="container py-3">
  <div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
    <h4 class="mb-0"><i class="fa-solid fa-table-cells"></i> <?= e($t('مصفوفة التحكيم','Review Matrix')) ?></h4>
    <form method="get" class="d-flex gap-2">
      <select class="form-select" name="conference_id" onchange="this.form.submit()">
        <?php foreach($confs as $c): ?>
          <option value="<?= e((string)$c['id']) ?>" <?= ((int)$c['id']===$confId?'selected':'') ?>>
            <?= e($lang==='ar' ? (string)($c['title_ar']??'') : (string)($c['title_en']??'')) ?>
          </option>
        <?php endforeach; ?>
      </select>
    </form>
  </div>

  <div class="card border-0 shadow-sm">
    <div class="table-responsive">
      <table class="table table-hover mb-0">
        <thead class="table-light">
          <tr>
            <th>#</th>
            <th><?= e($t('العنوان','Title')) ?></th>
            <th><?= e($t('عدد التوزيعات','Assignments')) ?></th>
          </tr>
        </thead>
        <tbody>
          <?php foreach($rows as $r): ?>
            <tr>
              <td class="text-muted"><?= e((string)$r['id']) ?></td>
              <td><?= e((string)($r['title_ar']??$r['title_en']??'—')) ?></td>
              <td><span class="badge bg-secondary"><?= e((string)($r['assignments_count']??0)) ?></span></td>
            </tr>
          <?php endforeach; ?>
          <?php if(empty($rows)): ?><tr><td colspan="3" class="text-center text-muted py-4">—</td></tr><?php endif; ?>
        </tbody>
      </table>
    </div>
  </div>
</div>
<?php require __DIR__ . '/../../layouts/footer.php'; ?>
