<?php require __DIR__ . '/../../layouts/header.php'; $lang=current_lang(); ?>
<div class="container">
  <h4 class="mb-3"><i class="fa-solid fa-gavel me-2"></i><?= e($lang==='ar'?'لوحة القرارات':'Decision Board') ?></h4>

  <div class="card border-0 shadow-sm">
    <div class="card-body">
      <div class="table-responsive">
        <table class="table align-middle">
          <thead><tr><th>#</th><th><?= e($lang==='ar'?'العنوان':'Title') ?></th><th><?= e($lang==='ar'?'الحالة':'Status') ?></th><th><?= e($lang==='ar'?'القرار':'Decision') ?></th><th style="min-width:360px"><?= e($lang==='ar'?'تحديث القرار':'Update') ?></th></tr></thead>
          <tbody>
          <?php foreach(($rows??[]) as $r): ?>
            <tr>
              <td><?= e((string)$r['id']) ?></td>
              <td class="fw-bold"><?= e($lang==='ar'?(string)$r['title_ar']:(string)$r['title_en']) ?></td>
              <td><span class="badge bg-secondary"><?= e((string)$r['status']) ?></span></td>
              <td><?= e((string)($r['decision']??'')) ?></td>
              <td>
                <form method="post" action="<?= e(base_path('admin/decision-board/decide')) ?>" class="d-flex gap-2 flex-wrap">
                  <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
                  <input type="hidden" name="submission_id" value="<?= e((string)$r['id']) ?>">
                  <select class="form-select form-select-sm" name="decision" style="width:160px">
                    <?php foreach(['accept','minor','major','reject'] as $d): ?>
                      <option value="<?= e($d) ?>" <?= ((string)($r['decision']??'')===$d?'selected':'') ?>><?= e($d) ?></option>
                    <?php endforeach; ?>
                  </select>
                  <input class="form-control form-control-sm" name="summary" placeholder="<?= e($lang==='ar'?'ملخص للباحث':'Summary to author') ?>" value="<?= e((string)($r['summary']??'')) ?>">
                  <button class="btn btn-sm btn-primary"><?= e($lang==='ar'?'حفظ':'Save') ?></button>
                </form>
              </td>
            </tr>
          <?php endforeach; ?>
          <?php if(empty($rows)): ?><tr><td colspan="5" class="text-center text-muted py-4">—</td></tr><?php endif; ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>

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