<?php use App\Helpers\Helper; ?>
<div class="mb-4"><h1 class="admin-page-title">My Profile</h1></div>
<div class="row g-4">
  <div class="col-md-4">
    <div class="form-card text-center">
      <div class="d-flex justify-content-center mb-3">
        <?php if ($tenant['photo']): ?>
        <img src="<?= APP_URL ?>/uploads/avatars/<?= Helper::e($tenant['photo']) ?>" class="rounded-circle" width="100" height="100" style="object-fit:cover">
        <?php else: ?>
        <div class="rounded-circle bg-primary d-flex align-items-center justify-content-center text-white fw-800" style="width:100px;height:100px;font-size:2.5rem">
          <?= strtoupper(substr($tenant['first_name'],0,1)) ?>
        </div>
        <?php endif; ?>
      </div>
      <h5 class="fw-700"><?= Helper::e($tenant['first_name'].' '.$tenant['last_name']) ?></h5>
      <div class="text-muted small"><?= Helper::e($tenant['tenant_code']) ?></div>
      <span class="badge bg-success mt-2"><?= ucfirst($tenant['status']) ?></span>
      <hr>
      <div class="small text-start">
        <div class="mb-2"><i class="bi bi-envelope me-2 text-primary"></i><?= Helper::e($tenant['email'] ?? '—') ?></div>
        <div class="mb-2"><i class="bi bi-phone me-2 text-primary"></i><?= Helper::e($tenant['phone']) ?></div>
        <div class="mb-2"><i class="bi bi-geo-alt me-2 text-primary"></i><?= Helper::e($tenant['address'] ?? '—') ?></div>
        <div class="mb-2"><i class="bi bi-person-badge me-2 text-primary"></i>National ID: <?= Helper::e($tenant['national_id'] ?? '—') ?></div>
      </div>
    </div>
  </div>
  <div class="col-md-8">
    <div class="form-card">
      <div class="form-section-title">Update Profile</div>
      <form method="POST" action="<?= APP_URL ?>/tenant/profile" enctype="multipart/form-data">
        <?= Helper::csrf() ?>
        <div class="row g-3">
          <div class="col-md-6"><label class="form-label">Phone *</label><input type="tel" name="phone" class="form-control" value="<?= Helper::e($tenant['phone']) ?>" required></div>
          <div class="col-md-6"><label class="form-label">Alt Phone</label><input type="tel" name="phone_alt" class="form-control" value="<?= Helper::e($tenant['phone_alt']??'') ?>"></div>
          <div class="col-md-6"><label class="form-label">Occupation</label><input type="text" name="occupation" class="form-control" value="<?= Helper::e($tenant['occupation']??'') ?>"></div>
          <div class="col-md-6"><label class="form-label">Employer</label><input type="text" name="employer" class="form-control" value="<?= Helper::e($tenant['employer']??'') ?>"></div>
          <div class="col-12"><label class="form-label">Home Address</label><textarea name="address" class="form-control" rows="2"><?= Helper::e($tenant['address']??'') ?></textarea></div>
          <div class="col-md-6"><label class="form-label">Emergency Contact Name</label><input type="text" name="emergency_contact_name" class="form-control" value="<?= Helper::e($tenant['emergency_contact_name']??'') ?>"></div>
          <div class="col-md-6"><label class="form-label">Emergency Contact Phone</label><input type="tel" name="emergency_contact_phone" class="form-control" value="<?= Helper::e($tenant['emergency_contact_phone']??'') ?>"></div>
          <div class="col-md-6"><label class="form-label">Profile Photo</label><input type="file" name="photo" class="form-control" accept="image/*"></div>
        </div>
        <button type="submit" class="btn btn-primary mt-4 px-5"><i class="bi bi-save me-2"></i>Save Changes</button>
      </form>
    </div>
  </div>
</div>
