<?php /** @var array $row */ ?>
<div class="topbar">
  <div>
    <h2><?= e($title) ?></h2>
    <div class="small">الحقول الأساسية للمقاول.</div>
  </div>
</div>

<form class="card" method="post">
  <?= csrf_field() ?>
  <div class="grid" style="grid-template-columns: 1fr 1fr">
    <div>
      <label class="small">رمز المقاول</label>
      <input class="input" name="code" value="<?= e($row['code'] ?? '') ?>" placeholder="CTR-001">
    </div>
    <div>
      <label class="small">اسم المقاول</label>
      <input class="input" name="name" value="<?= e($row['name'] ?? '') ?>">
    </div>
    <div>
      <label class="small">الهاتف</label>
      <input class="input" name="phone" value="<?= e($row['phone'] ?? '') ?>" placeholder="05xxxxxxxx">
    </div>
    <div>
      <label class="small">البريد الإلكتروني</label>
      <input class="input" name="email" value="<?= e($row['email'] ?? '') ?>" placeholder="name@example.com">
    </div>
    <div>
      <label class="small">رقم الرخصة</label>
      <input class="input" name="license_no" value="<?= e($row['license_no'] ?? '') ?>">
    </div>
    <div>
      <label class="small">الحالة</label>
      <label style="display:flex;gap:8px;align-items:center;margin-top:6px">
        <input type="checkbox" name="is_active" value="1" <?= intval($row['is_active'] ?? 1)===1?'checked':'' ?>>
        <span class="small">نشط</span>
      </label>
    </div>
  </div>

  <div style="margin-top:10px">
    <label class="small">العنوان</label>
    <input class="input" name="address" value="<?= e($row['address'] ?? '') ?>">
  </div>

  <div style="margin-top:10px">
    <label class="small">ملاحظات</label>
    <textarea class="input" name="notes" rows="4"><?= e($row['notes'] ?? '') ?></textarea>
  </div>

  <div class="actions" style="margin-top:12px">
    <button class="btn primary">حفظ</button>
    <a class="btn" href="<?= e(url('/index.php?page=contractors')) ?>">عودة</a>
  </div>
</form>
