<?php require __DIR__ . '/../../layouts/header.php'; $lang=current_lang(); ?>
<?php $t=fn($ar,$en)=>($lang==='ar'?$ar:$en); $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-users"></i> <?= e($t('المحكمون','Reviewers')) ?></h4>
  </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('الاسم','Name')) ?></th>
            <th><?= e($t('البريد','Email')) ?></th>
            <th style="width:360px"><?= e($t('تقييم','Rate')) ?></th>
          </tr>
        </thead>
        <tbody>
          <?php foreach($rows as $r): ?>
            <?php $id=(int)$r['id']; $name=trim(($r['first_name']??'').' '.($r['last_name']??'')); ?>
            <tr>
              <td class="text-muted"><?= e((string)$id) ?></td>
              <td><?= e($name) ?></td>
              <td class="text-muted"><?= e((string)($r['email']??'')) ?></td>
              <td>
                <form class="d-flex gap-2" method="post" action="<?= e(base_path('admin/reviewers/rate')) ?>">
                  <input type="hidden" name="reviewer_id" value="<?= e((string)$id) ?>">
                  <select class="form-select form-select-sm" name="score" style="max-width:110px">
                    <option value="5">5</option><option value="4">4</option><option value="3">3</option><option value="2">2</option><option value="1">1</option>
                  </select>
                  <input class="form-control form-control-sm" name="notes" placeholder="<?= e($t('ملاحظات','Notes')) ?>">
                  <button class="btn btn-sm btn-primary"><i class="fa-solid fa-star"></i> <?= e($t('حفظ','Save')) ?></button>
                </form>
              </td>
            </tr>
          <?php endforeach; ?>
          <?php if(empty($rows)): ?><tr><td colspan="4" class="text-center text-muted py-4">—</td></tr><?php endif; ?>
        </tbody>
      </table>
    </div>
  </div>
</div>
<?php require __DIR__ . '/../../layouts/footer.php'; ?>
