<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-calendar-alt me-2"></i><?= e($title) ?></h5>
            </div>
            <div class="card-body">
                <form method="POST" action="<?= e($formAction) ?>" data-ajax="true">
                    <?= csrf_field() ?>
                    <div class="row g-3">
                        <div class="col-md-6">
                            <label class="form-label"><?= lang('board.term_name') ?> (EN) <span class="text-danger">*</span></label>
                            <input type="text" name="term_name_en" class="form-control" value="<?= e($term['term_name_en'] ?? '') ?>" required>
                            <div class="invalid-feedback" data-field="term_name_en"></div>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label"><?= lang('board.term_name') ?> (AR) <span class="text-danger">*</span></label>
                            <input type="text" name="term_name_ar" class="form-control" value="<?= e($term['term_name_ar'] ?? '') ?>" required dir="rtl">
                            <div class="invalid-feedback" data-field="term_name_ar"></div>
                        </div>
                        <div class="col-md-4">
                            <label class="form-label"><?= lang('board.start_date') ?> <span class="text-danger">*</span></label>
                            <input type="date" name="start_date" class="form-control" value="<?= e($term['start_date'] ?? '') ?>" required>
                            <div class="invalid-feedback" data-field="start_date"></div>
                        </div>
                        <div class="col-md-4">
                            <label class="form-label"><?= lang('board.end_date') ?> <span class="text-danger">*</span></label>
                            <input type="date" name="end_date" class="form-control" value="<?= e($term['end_date'] ?? '') ?>" required>
                            <div class="invalid-feedback" data-field="end_date"></div>
                        </div>
                        <div class="col-md-4">
                            <label class="form-label"><?= lang('common.status') ?> <span class="text-danger">*</span></label>
                            <select name="status" class="form-select" required>
                                <option value="upcoming" <?= selected('upcoming', $term['status'] ?? 'upcoming') ?>>Upcoming</option>
                                <option value="active" <?= selected('active', $term['status'] ?? '') ?>>Active</option>
                                <option value="ended" <?= selected('ended', $term['status'] ?? '') ?>>Ended</option>
                            </select>
                            <div class="invalid-feedback" data-field="status"></div>
                        </div>
                        <div class="col-md-4">
                            <label class="form-label"><?= lang('board.election_date') ?></label>
                            <input type="date" name="election_date" class="form-control" value="<?= e($term['election_date'] ?? '') ?>">
                        </div>
                        <div class="col-12">
                            <label class="form-label"><?= lang('board.notes') ?></label>
                            <textarea name="notes" class="form-control" rows="3"><?= e($term['notes'] ?? '') ?></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="/board/terms" class="btn btn-secondary"><?= lang('common.cancel') ?></a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>