<?php
$__template->layout('Layout.main');
?>
<?php $__template->section('title'); ?>إضافة أكاديمية جديدة<?php $__template->endSection(); ?>

<?php $__template->section('page_actions'); ?>
<a href="/sa/academies" class="btn btn-outline"><i data-lucide="arrow-right" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> رجوع</a>
<?php $__template->endSection(); ?>

<?php $__template->section('content'); ?>

<form method="POST" action="/sa/academies">
    <?= csrf_field() ?>

    <div class="card" style="margin-bottom:20px;">
        <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;">
            <h3 style="margin:0;font-size:16px;font-weight:600;">بيانات الأكاديمية</h3>
        </div>
        <div style="padding:20px;display:grid;grid-template-columns:repeat(auto-fit, minmax(250px, 1fr));gap:15px;">
            <div>
                <label class="form-label">الكود <span style="color:#DC2626;">*</span></label>
                <input type="text" name="code" value="<?= e(old('code') ?? '') ?>" class="form-input" dir="ltr" required maxlength="30" placeholder="مثال: ACAD_SWIM_01">
            </div>
            <div>
                <label class="form-label">الاسم بالعربي <span style="color:#DC2626;">*</span></label>
                <input type="text" name="name_ar" value="<?= e(old('name_ar') ?? '') ?>" class="form-input" required maxlength="300">
            </div>
            <div>
                <label class="form-label">الاسم بالإنجليزي</label>
                <input type="text" name="name_en" value="<?= e(old('name_en') ?? '') ?>" class="form-input" dir="ltr" maxlength="300">
            </div>
            <div>
                <label class="form-label">اللعبة / النشاط الرياضي <span style="color:#DC2626;">*</span></label>
                <select name="discipline_id" class="form-select" required>
                    <option value="">اختر...</option>
                    <?php foreach ($disciplines as $disc): ?>
                    <option value="<?= (int) $disc['id'] ?>" <?= old('discipline_id') == $disc['id'] ? 'selected' : '' ?>><?= e($disc['name_ar']) ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div>
                <label class="form-label">نوع الأكاديمية <span style="color:#DC2626;">*</span></label>
                <select name="academy_type" class="form-select" required>
                    <option value="internal" <?= (old('academy_type') ?? '') === 'internal' ? 'selected' : '' ?>>داخلية</option>
                    <option value="external" <?= old('academy_type') === 'external' ? 'selected' : '' ?>>خارجية</option>
                    <option value="partnership" <?= old('academy_type') === 'partnership' ? 'selected' : '' ?>>شراكة</option>
                </select>
            </div>
            <div>
                <label class="form-label">مسؤول التواصل</label>
                <input type="text" name="contact_person" value="<?= e(old('contact_person') ?? '') ?>" class="form-input" maxlength="200">
            </div>
            <div>
                <label class="form-label">هاتف التواصل</label>
                <input type="text" name="contact_phone" value="<?= e(old('contact_phone') ?? '') ?>" class="form-input" dir="ltr" maxlength="30">
            </div>
            <div>
                <label class="form-label">البريد الإلكتروني</label>
                <input type="email" name="contact_email" value="<?= e(old('contact_email') ?? '') ?>" class="form-input" dir="ltr" maxlength="200">
            </div>
            <div style="grid-column:1 / -1;">
                <label class="form-label">الوصف</label>
                <textarea name="description_ar" class="form-input" rows="3" placeholder="وصف الأكاديمية..."><?= e(old('description_ar') ?? '') ?></textarea>
            </div>
        </div>
    </div>

    <div style="display:flex;gap:10px;justify-content:flex-start;">
        <button type="submit" class="btn btn-primary"><i data-lucide="save" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> حفظ</button>
        <a href="/sa/academies" class="btn btn-outline">إلغاء</a>
    </div>
</form>

<script>
document.addEventListener('DOMContentLoaded', function() {
    if (typeof lucide !== 'undefined') lucide.createIcons();
});
</script>
<?php $__template->endSection(); ?>
