<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-edit me-2"></i>Edit Sport</h5></div>
    <div class="card-body">
        <form method="POST" action="/sports/<?= $sport['id'] ?>" data-ajax="true">
            <?= csrf_field() ?>
            <div class="row g-3">
                <div class="col-md-4">
                    <label class="form-label">Sport Code</label>
                    <input type="text" class="form-control" value="<?= e($sport['sport_code']) ?>" disabled>
                </div>
                <div class="col-md-4">
                    <label class="form-label">Category <span class="text-danger">*</span></label>
                    <select name="category_id" class="form-select" required>
                        <?php foreach ($categories as $c): ?>
                        <option value="<?= $c['id'] ?>" <?= selected($c['id'], $sport['category_id']) ?>><?= e($c['name_en']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="col-md-4">
                    <label class="form-label">Gender</label>
                    <select name="gender_restriction" class="form-select">
                        <?php foreach (['both','male','female','mixed'] as $g): ?>
                        <option value="<?= $g ?>" <?= selected($g, $sport['gender_restriction']) ?>><?= ucfirst($g) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="col-md-6">
                    <label class="form-label">Name (EN) <span class="text-danger">*</span></label>
                    <input type="text" name="name_en" class="form-control" value="<?= e($sport['name_en']) ?>" required>
                </div>
                <div class="col-md-6">
                    <label class="form-label">Name (AR) <span class="text-danger">*</span></label>
                    <input type="text" name="name_ar" class="form-control" dir="rtl" value="<?= e($sport['name_ar']) ?>" required>
                </div>
                <div class="col-12">
                    <label class="form-label">Description</label>
                    <textarea name="description_en" class="form-control" rows="3"><?= e($sport['description_en'] ?? '') ?></textarea>
                </div>
                <div class="col-md-3"><label class="form-label">Min Players</label><input type="number" name="min_players" class="form-control" value="<?= $sport['min_players'] ?>"></div>
                <div class="col-md-3"><label class="form-label">Max Players</label><input type="number" name="max_players" class="form-control" value="<?= $sport['max_players'] ?>"></div>
                <div class="col-md-3"><label class="form-label">Sort Order</label><input type="number" name="sort_order" class="form-control" value="<?= $sport['sort_order'] ?>"></div>
                <div class="col-md-3">
                    <div class="form-check mt-4"><input type="checkbox" name="team_sport" value="1" class="form-check-input" <?= checked(1, $sport['team_sport']) ?>><label class="form-check-label">Team Sport</label></div>
                    <div class="form-check"><input type="checkbox" name="is_active" value="1" class="form-check-input" <?= checked(1, $sport['is_active']) ?>><label class="form-check-label">Active</label></div>
                    <div class="form-check"><input type="checkbox" name="requires_medical_clearance" value="1" class="form-check-input" <?= checked(1, $sport['requires_medical_clearance']) ?>><label class="form-check-label">Medical Clearance</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="/sports" class="btn btn-secondary"><?= lang('common.cancel') ?></a>
            </div>
        </form>
    </div>
</div>
</div>
</div>