<?php $pageTitle = 'Add Contact Person'; include __DIR__ . '/../shared/header.php'; ?>

<div class="page-header">
  <div class="page-title"><i class="bi bi-person-plus me-2"></i>Add Contact Person</div>
  <a href="javascript:history.back()" class="btn btn-outline-secondary"><i class="bi bi-arrow-left me-1"></i>Back</a>
</div>

<div class="row"><div class="col-lg-6">
  <div class="card"><div class="card-body">
    <form method="POST">
      <input type="hidden" name="csrf_token" value="<?= csrfToken() ?>">
      <div class="mb-3">
        <label class="form-label">Company <span class="text-danger">*</span></label>
        <select name="company_id" class="form-select" required>
          <option value="">Select company...</option>
          <?php foreach ($companies as $co): ?>
            <option value="<?= $co['company_id'] ?>" <?= (int)($_GET['company_id'] ?? 0) === (int)$co['company_id'] ? 'selected' : '' ?>>
              <?= e($co['company_name']) ?>
            </option>
          <?php endforeach; ?>
        </select>
      </div>
      <div class="mb-3">
        <label class="form-label">Full Name <span class="text-danger">*</span></label>
        <input type="text" name="contact_name" class="form-control" required placeholder="Contact person's full name">
      </div>
      <div class="mb-3">
        <label class="form-label">Position / Title</label>
        <input type="text" name="position" class="form-control" placeholder="e.g. Quality Manager">
      </div>
      <div class="row g-3 mb-4">
        <div class="col-md-6">
          <label class="form-label">Phone</label>
          <input type="text" name="phone_number" class="form-control" placeholder="+233...">
        </div>
        <div class="col-md-6">
          <label class="form-label">Email</label>
          <input type="email" name="email" class="form-control">
        </div>
      </div>
      <div class="d-flex gap-2">
        <button type="submit" class="btn btn-primary"><i class="bi bi-check-lg me-1"></i>Add Contact</button>
        <a href="javascript:history.back()" class="btn btn-outline-secondary">Cancel</a>
      </div>
    </form>
  </div></div>
</div></div>

<?php include __DIR__ . '/../shared/footer.php'; ?>
