<div class="row justify-content-center"><div class="col-lg-8"><div class="card">
    <div class="card-header"><h5 class="mb-0"><?= $point ? lang('cards.edit_access_point') : lang('cards.create_access_point') ?></h5></div>
    <div class="card-body">
        <form method="POST" action="<?= $formAction ?>" data-ajax="true"><?= csrf_field() ?>
            <div class="row g-3">
                <div class="col-md-4"><label class="form-label">Code *</label><input type="text" name="point_code" class="form-control" value="<?= e($point['point_code'] ?? '') ?>" required><div class="invalid-feedback" data-field="point_code"></div></div>
                <div class="col-md-4"><label class="form-label">Name (EN) *</label><input type="text" name="name_en" class="form-control" value="<?= e($point['name_en'] ?? '') ?>" required></div>
                <div class="col-md-4"><label class="form-label">Name (AR) *</label><input type="text" name="name_ar" class="form-control" value="<?= e($point['name_ar'] ?? '') ?>" required></div>
                <div class="col-md-6"><label class="form-label">Type *</label><select name="point_type" class="form-select" required>
                    <?php foreach(['main_gate','facility_entrance','parking','pool','gym','court','other'] as $v): ?><option value="<?= $v ?>" <?= selected($v, $point['point_type'] ?? '') ?>><?= ucfirst(str_replace('_',' ',$v)) ?></option><?php endforeach; ?>
                </select></div>
                <div class="col-md-6"><label class="form-label">Hardware *</label><select name="hardware_type" class="form-select" required>
                    <?php foreach(['turnstile','gate','door','barrier','scanner','manual'] as $v): ?><option value="<?= $v ?>" <?= selected($v, $point['hardware_type'] ?? 'manual') ?>><?= ucfirst($v) ?></option><?php endforeach; ?>
                </select></div>
                <div class="col-md-4"><label class="form-label">Direction *</label><select name="direction" class="form-select" required>
                    <?php foreach(['entry','exit','both'] as $v): ?><option value="<?= $v ?>" <?= selected($v, $point['direction'] ?? 'both') ?>><?= ucfirst($v) ?></option><?php endforeach; ?>
                </select></div>
                <div class="col-md-4"><label class="form-label">Facility</label><select name="facility_id" class="form-select"><option value="">None</option>
                    <?php foreach($facilities as $f): ?><option value="<?= $f['id'] ?>" <?= selected($f['id'], $point['facility_id'] ?? '') ?>><?= e($f['name_en']) ?></option><?php endforeach; ?>
                </select></div>
                <div class="col-md-4"><label class="form-label">Location</label><input type="text" name="location" class="form-control" value="<?= e($point['location'] ?? '') ?>"></div>
                <div class="col-md-4"><label class="form-label">Hardware ID</label><input type="text" name="hardware_id" class="form-control" value="<?= e($point['hardware_id'] ?? '') ?>"></div>
                <div class="col-md-4"><div class="form-check mt-4"><input type="checkbox" name="is_active" class="form-check-input" id="is_active" <?= checked(1, $point['is_active'] ?? 1) ?>><label class="form-check-label" for="is_active">Active</label></div></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="/access-points" class="btn btn-secondary"><?= lang('common.cancel') ?></a></div>
        </form>
    </div>
</div></div></div>