<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?><?= $coach ? 'تعديل مدرب: ' . e($coach['full_name_ar']) : 'إضافة مدرب سباحة' ?><?php $__template->endSection(); ?>

<?php $__template->section('page_actions'); ?>
<a href="/sa/swimming/coaches" 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="<?= $coach ? '/sa/swimming/coaches/' . (int) $coach['id'] : '/sa/swimming/coaches' ?>">
    <?= csrf_field() ?>

    <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="waves" 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:16px;">
                <div class="form-group">
                    <label class="form-label">الاسم بالعربي <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="full_name_ar" value="<?= e(old('full_name_ar') ?: ($coach['full_name_ar'] ?? '')) ?>" class="form-input" required>
                </div>
                <div class="form-group">
                    <label class="form-label">الاسم بالإنجليزي</label>
                    <input type="text" name="full_name_en" value="<?= e(old('full_name_en') ?: ($coach['full_name_en'] ?? '')) ?>" class="form-input" style="direction:ltr;text-align:left;">
                </div>
                <div class="form-group">
                    <label class="form-label">الرقم القومي</label>
                    <input type="text" name="national_id" value="<?= e(old('national_id') ?: ($coach['national_id'] ?? '')) ?>" class="form-input" maxlength="14" style="direction:ltr;text-align:left;" <?= $coach ? 'readonly' : '' ?>>
                </div>
                <div class="form-group">
                    <label class="form-label">الهاتف</label>
                    <input type="text" name="phone" value="<?= e(old('phone') ?: ($coach['phone'] ?? '')) ?>" class="form-input" style="direction:ltr;text-align:left;">
                </div>
                <div class="form-group">
                    <label class="form-label">نوع التوظيف <span style="color:#DC2626;">*</span></label>
                    <select name="employment_type" class="form-select" required>
                        <?php $et = old('employment_type') ?: ($coach['employment_type'] ?? 'freelance'); ?>
                        <option value="freelance" <?= $et === 'freelance' ? 'selected' : '' ?>>مستقل (Freelance)</option>
                        <option value="staff" <?= $et === 'staff' ? 'selected' : '' ?>>موظف (Staff)</option>
                        <option value="contract" <?= $et === 'contract' ? 'selected' : '' ?>>تعاقد (Contract)</option>
                    </select>
                </div>
            </div>
        </div>
    </div>

    <button type="submit" class="btn btn-primary" style="padding:14px 30px;font-size:15px;">
        <i data-lucide="check" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> <?= $coach ? 'حفظ التعديلات' : 'إضافة المدرب' ?>
    </button>
</form>

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