<div class="container-fluid fade-in">
    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="card">
                <div class="card-header"><h5 class="mb-0"><i class="fas fa-hourglass-half me-2"></i><?= lang('applications.add_to_waitlist') ?></h5></div>
                <div class="card-body">
                    <form method="POST" action="/waiting-list/entries" data-ajax="true">
                        <?= csrf_field() ?>
                        <div class="row g-3">
                            <div class="col-md-6">
                                <label class="form-label">Waiting List <span class="text-danger">*</span></label>
                                <select name="waiting_list_id" class="form-select select2" required>
                                    <option value="">-</option>
                                    <?php foreach ($waitingLists as $wl): ?>
                                    <option value="<?= $wl['id'] ?>"><?= e(current_lang() === 'ar' ? $wl['type_name_ar'] : $wl['type_name_en']) ?> (<?= $wl['current_entries'] ?><?= $wl['max_entries'] ? '/' . $wl['max_entries'] : '' ?>)</option>
                                    <?php endforeach; ?>
                                </select>
                                <div class="invalid-feedback" data-field="waiting_list_id"></div>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Priority</label>
                                <select name="priority" class="form-select">
                                    <option value="normal">Normal</option>
                                    <option value="high">High</option>
                                    <option value="vip">VIP</option>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Applicant Name <span class="text-danger">*</span></label>
                                <input type="text" name="applicant_name" class="form-control" required>
                                <div class="invalid-feedback" data-field="applicant_name"></div>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Phone <span class="text-danger">*</span></label>
                                <input type="text" name="applicant_phone" class="form-control" required>
                                <div class="invalid-feedback" data-field="applicant_phone"></div>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Email</label>
                                <input type="email" name="applicant_email" class="form-control">
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">National ID</label>
                                <input type="text" name="applicant_national_id" class="form-control" maxlength="20">
                            </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="/waiting-list" class="btn btn-secondary"><?= lang('common.cancel') ?></a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>