<?php require __DIR__ . '/../../layouts/header.php'; $lang=current_lang(); ?>
<div class="container" style="max-width:980px">
  <h4 class="mb-3"><i class="fa-solid fa-plus me-2"></i><?= e($lang==='ar'?'إضافة قالب بريد':'Add Email Template') ?></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('admin/email-templates/store')) ?>" class="row g-3">
      <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
      <div class="col-md-6"><label class="form-label">template_key</label><input class="form-control" name="template_key" required></div>
      <div class="col-md-6">
        <label class="form-label"><?= e($lang==='ar'?'مفعل':'Active') ?></label>
        <select class="form-select" name="is_active"><option value="1">1</option><option value="0">0</option></select>
      </div>
      <div class="col-md-6"><label class="form-label">subject_en</label><input class="form-control" name="subject_en" required></div>
      <div class="col-md-6"><label class="form-label">subject_ar</label><input class="form-control" name="subject_ar" required></div>
      <div class="col-md-6"><label class="form-label">body_en</label><textarea class="form-control" name="body_en" rows="8" required></textarea></div>
      <div class="col-md-6"><label class="form-label">body_ar</label><textarea class="form-control" name="body_ar" rows="8" required></textarea></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('admin/email-templates')) ?>"><?= e($lang==='ar'?'رجوع':'Back') ?></a>
      </div>
    </form>
  </div></div>
</div>
<?php require __DIR__ . '/../../layouts/footer.php'; ?>
