<?php require __DIR__ . '/../../layouts/header.php'; $page_title = 'Review Matrix'; ?>

<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
  <h3 class="mb-0"><i class="fa-solid fa-table me-2"></i>Review Matrix</h3>
  <a class="btn btn-outline-secondary btn-rounded" href="<?= e(base_path('admin/decision-board?conference_id='.(int)$sub['conference_id'].'&round_no='.(int)$round_no)) ?>">
    <i class="fa-solid fa-arrow-left me-2"></i><?= e(trans('back')) ?>
  </a>
</div>

<div class="card shadow-sm border-0 mb-3">
  <div class="card-body">
    <div class="fw-bold"><?= e((string)($sub['submission_no']??'')) ?> — <?= e((string)($sub['title']??'')) ?></div>
    <?php if (!empty($sub['title_ar'])): ?><div class="small text-muted"><?= e((string)$sub['title_ar']) ?></div><?php endif; ?>
  </div>
</div>

<div class="card shadow-sm border-0">
  <div class="card-body">
    <div class="table-responsive">
      <table class="table table-hover align-middle mb-0">
        <thead><tr><th>Reviewer</th><th>Status</th><th>Score</th><th>Rec</th><th>File</th><th>Submitted</th></tr></thead>
        <tbody>
          <?php foreach ($rows as $r): ?>
            <tr>
              <td><?= e(trim((string)$r['first_name'].' '.(string)$r['last_name'])) ?><div class="small text-muted"><?= e((string)$r['email']) ?></div></td>
              <td><span class="badge <?= ($r['status']==='submitted')?'bg-success':'bg-primary' ?>"><?= e((string)$r['status']) ?></span></td>
              <td><?= e((string)($r['score_overall'] ?? '')) ?></td>
              <td><?= e((string)($r['recommendation'] ?? '')) ?></td>
              <td>
                <?php if (!empty($r['review_file_path'])): ?>
                  <a class="btn btn-sm btn-outline-dark btn-rounded" href="<?= e(base_path('storage/'.$r['review_file_path'])) ?>" target="_blank">
                    <i class="fa-solid fa-download me-2"></i>Download
                  </a>
                <?php else: ?>
                  <span class="text-muted">-</span>
                <?php endif; ?>
              </td>
              <td class="small text-muted"><?= e((string)($r['submitted_at'] ?? '')) ?></td>
            </tr>
          <?php endforeach; ?>
          <?php if (empty($rows)): ?><tr><td colspan="6" class="text-center text-muted py-4"><?= e(trans('no_data')) ?></td></tr><?php endif; ?>
        </tbody>
      </table>
    </div>
  </div>
</div>

<?php require __DIR__ . '/../../layouts/footer.php'; ?>
