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

<?php $__template->section('page_actions'); ?>
<a href="/sa/programs" class="btn btn-outline"><i data-lucide="arrow-right" style="width:15px;height:15px;vertical-align:middle;margin-left:4px;"></i> العودة للقائمة</a>
<?php $__template->endSection(); ?>

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

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

    <!-- Basic Information -->
    <div class="card" style="margin-bottom:20px;">
        <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;display:flex;align-items:center;gap:8px;">
            <i data-lucide="book-open" style="width:18px;height:18px;color:#0D7377;"></i>
            <h3 style="margin:0;color:#0D7377;font-size:15px;">البيانات الأساسية</h3>
        </div>
        <div style="padding:20px;">
            <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;">
                <div class="form-group">
                    <label class="form-label">كود البرنامج <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="code" value="<?= e(old('code')) ?>" class="form-input" required placeholder="مثال: PROG-SWIM-01" style="direction:ltr;text-align:left;text-transform:uppercase;">
                </div>
                <div class="form-group">
                    <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 placeholder="مثال: برنامج السباحة للمبتدئين">
                </div>
                <div class="form-group">
                    <label class="form-label">الاسم بالإنجليزي</label>
                    <input type="text" name="name_en" value="<?= e(old('name_en')) ?>" class="form-input" placeholder="e.g. Beginner Swimming" style="direction:ltr;text-align:left;">
                </div>
            </div>
            <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;margin-top:15px;">
                <div class="form-group">
                    <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 $d): ?>
                        <option value="<?= (int) $d['id'] ?>" <?= old('discipline_id') == $d['id'] ? 'selected' : '' ?>><?= e($d['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">الأكاديمية (اختياري)</label>
                    <select name="academy_id" class="form-select">
                        <option value="">-- بدون أكاديمية --</option>
                        <?php foreach ($academies as $a): ?>
                        <option value="<?= (int) $a['id'] ?>" <?= old('academy_id') == $a['id'] ? 'selected' : '' ?>><?= e($a['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">نوع البرنامج</label>
                    <select name="program_type" class="form-select">
                        <option value="">-- اختر النوع --</option>
                        <?php foreach ($programTypes as $key => $label): ?>
                        <option value="<?= e($key) ?>" <?= old('program_type') === $key ? 'selected' : '' ?>><?= e($label) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
        </div>
    </div>

    <!-- Age & Level -->
    <div class="card" style="margin-bottom:20px;">
        <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;display:flex;align-items:center;gap:8px;">
            <i data-lucide="users" style="width:18px;height:18px;color:#0D7377;"></i>
            <h3 style="margin:0;color:#0D7377;font-size:15px;">الفئة العمرية والمستوى</h3>
        </div>
        <div style="padding:20px;">
            <div style="display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:20px;">
                <div class="form-group">
                    <label class="form-label">العمر من</label>
                    <input type="number" name="age_from" value="<?= e(old('age_from')) ?>" class="form-input" min="0" max="99" placeholder="4" style="direction:ltr;text-align:left;">
                </div>
                <div class="form-group">
                    <label class="form-label">العمر إلى</label>
                    <input type="number" name="age_to" value="<?= e(old('age_to')) ?>" class="form-input" min="0" max="99" placeholder="12" style="direction:ltr;text-align:left;">
                </div>
                <div class="form-group">
                    <label class="form-label">الجنس</label>
                    <select name="gender_restriction" class="form-select">
                        <option value="mixed" <?= old('gender_restriction', 'mixed') === 'mixed' ? 'selected' : '' ?>>مختلط</option>
                        <option value="male" <?= old('gender_restriction') === 'male' ? 'selected' : '' ?>>ذكور فقط</option>
                        <option value="female" <?= old('gender_restriction') === 'female' ? 'selected' : '' ?>>إناث فقط</option>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">المستوى</label>
                    <select name="skill_level" class="form-select">
                        <option value="">-- الكل --</option>
                        <?php foreach ($skillLevels as $key => $label): ?>
                        <option value="<?= e($key) ?>" <?= old('skill_level') === $key ? 'selected' : '' ?>><?= e($label) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
        </div>
    </div>

    <!-- Session Details -->
    <div class="card" style="margin-bottom:20px;">
        <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;display:flex;align-items:center;gap:8px;">
            <i data-lucide="clock" style="width:18px;height:18px;color:#0D7377;"></i>
            <h3 style="margin:0;color:#0D7377;font-size:15px;">تفاصيل الحصص</h3>
        </div>
        <div style="padding:20px;">
            <div style="display:grid;grid-template-columns:1fr 1fr;gap:20px;">
                <div class="form-group">
                    <label class="form-label">مدة الحصة (دقيقة)</label>
                    <input type="number" name="session_duration_minutes" value="<?= e(old('session_duration_minutes')) ?>" class="form-input" min="15" max="300" placeholder="60" style="direction:ltr;text-align:left;">
                </div>
                <div class="form-group">
                    <label class="form-label">عدد الحصص أسبوعياً</label>
                    <input type="number" name="sessions_per_week" value="<?= e(old('sessions_per_week')) ?>" class="form-input" min="1" max="14" placeholder="3" style="direction:ltr;text-align:left;">
                </div>
            </div>
            <div class="form-group" style="margin-top:15px;">
                <label class="form-label">وصف البرنامج</label>
                <textarea name="description_ar" class="form-input" rows="3" placeholder="وصف مختصر للبرنامج..."><?= e(old('description_ar')) ?></textarea>
            </div>
        </div>
    </div>

    <!-- Submit -->
    <div style="display:flex;gap:10px;justify-content:flex-start;">
        <button type="submit" class="btn btn-primary" style="padding:12px 30px;font-size:15px;">
            <i data-lucide="check" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> حفظ البرنامج
        </button>
        <a href="/sa/programs" class="btn btn-outline" style="padding:12px 30px;font-size:15px;">إلغاء</a>
    </div>
</form>

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