<div class="row justify-content-center">
    <div class="col-lg-10">
        <div class="card">
            <div class="card-header"><h5 class="mb-0"><i class="fas fa-exchange-alt me-2"></i><?= lang('board.create_transfer') ?></h5></div>
            <div class="card-body">
                <form method="POST" action="/transfers" data-ajax="true">
                    <?= csrf_field() ?>
                    <div class="row g-3">
                        <div class="col-md-6">
                            <label class="form-label">Transfer Type <span class="text-danger">*</span></label>
                            <select name="transfer_type_id" class="form-select" required>
                                <option value="">-- Select --</option>
                                <?php foreach ($transferTypes as $tt): ?>
                                <option value="<?= $tt['id'] ?>"><?= e($tt['name_en']) ?> (<?= e($tt['type_code']) ?>)</option>
                                <?php endforeach; ?>
                            </select><div class="invalid-feedback" data-field="transfer_type_id"></div>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">Reason <span class="text-danger">*</span></label>
                            <select name="reason" class="form-select" required>
                                <?php foreach (['inheritance','divorce','gift','sale','court_order','board_decision','other'] as $r): ?>
                                <option value="<?= $r ?>"><?= ucfirst(str_replace('_', ' ', $r)) ?></option>
                                <?php endforeach; ?>
                            </select><div class="invalid-feedback" data-field="reason"></div>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">From Member ID <span class="text-danger">*</span></label>
                            <input type="number" name="from_member_id" class="form-control" required placeholder="Enter member ID">
                            <div class="invalid-feedback" data-field="from_member_id"></div>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">Membership Type <span class="text-danger">*</span></label>
                            <select name="membership_type_id" class="form-select" required>
                                <option value="">-- Select --</option>
                                <?php foreach ($membershipTypes as $mt): ?>
                                <option value="<?= $mt['id'] ?>"><?= e($mt['name_en']) ?></option>
                                <?php endforeach; ?>
                            </select><div class="invalid-feedback" data-field="membership_type_id"></div>
                        </div>
                        <hr>
                        <h6>Recipient Information</h6>
                        <div class="col-md-6">
                            <label class="form-label">Recipient Name <span class="text-danger">*</span></label>
                            <input type="text" name="to_applicant_name" class="form-control" required>
                            <div class="invalid-feedback" data-field="to_applicant_name"></div>
                        </div>
                        <div class="col-md-3">
                            <label class="form-label">National ID</label>
                            <input type="text" name="to_applicant_national_id" class="form-control">
                        </div>
                        <div class="col-md-3">
                            <label class="form-label">Phone</label>
                            <input type="text" name="to_applicant_phone" class="form-control">
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">Relationship to Original Member</label>
                            <input type="text" name="relationship_to_original" class="form-control" placeholder="e.g. Son, Spouse">
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">New Membership Type (if different)</label>
                            <select name="new_membership_type_id" class="form-select">
                                <option value="">-- Same as original --</option>
                                <?php foreach ($membershipTypes as $mt): ?>
                                <option value="<?= $mt['id'] ?>"><?= e($mt['name_en']) ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                        <div class="col-12">
                            <label class="form-label">Reason Details</label>
                            <textarea name="reason_details" class="form-control" rows="3"></textarea>
                        </div>
                        <div class="col-12">
                            <label class="form-label">Notes</label>
                            <textarea name="notes" class="form-control" rows="2"></textarea>
                        </div>
                    </div>
                    <div class="mt-4 d-flex gap-2">
                        <button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i><?= lang('common.save') ?></button>
                        <a href="/transfers" class="btn btn-secondary"><?= lang('common.cancel') ?></a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>