<?php require __DIR__ . '/../layouts/header.php'; $lang=current_lang(); ?>
<?php $r = $row ?? []; ?>
<div class="container" style="max-width:980px">
  <h4 class="mb-3"><i class="fa-solid fa-pen-to-square me-2"></i><?= e($lang==='ar'?'تعديل بيانات البحث':'Edit Submission') ?></h4>
  <?php if (!empty($err)): ?><div class="alert alert-danger"><?= e((string)$err) ?></div><?php endif; ?>

  <div class="card border-0 shadow-sm">
    <div class="card-body">
      <form method="post" action="<?= e(base_path('author/work/save')) ?>" class="row g-3">
        <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
        <input type="hidden" name="id" value="<?= e((string)($r['id'] ?? '')) ?>">

        <div class="col-md-6">
          <label class="form-label"><?= e($lang==='ar'?'العنوان (EN)':'Title (EN)') ?></label>
          <input class="form-control" name="title_en" value="<?= e((string)($r['title_en'] ?? $r['title'] ?? '')) ?>" required>
        </div>
        <div class="col-md-6">
          <label class="form-label"><?= e($lang==='ar'?'العنوان (AR)':'Title (AR)') ?></label>
          <input class="form-control" name="title_ar" value="<?= e((string)($r['title_ar'] ?? '')) ?>" required>
        </div>

        <div class="col-12 d-flex gap-2">
          <button class="btn btn-primary btn-rounded"><?= e($lang==='ar'?'حفظ':'Save') ?></button>
          <a class="btn btn-outline-secondary btn-rounded" href="<?= e(base_path('author/submission?id='.(int)($r['id'] ?? 0))) ?>"><?= e($lang==='ar'?'رجوع':'Back') ?></a>
        </div>
      </form>
    </div>
  </div>
</div>
<?php require __DIR__ . '/../layouts/footer.php'; ?>
