<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>المدرب: <?= e($coach['full_name_ar'] ?? '') ?><?php $__template->endSection(); ?>

<?php $__template->section('page_actions'); ?>
<?php if (can('sa.coach.manage')): ?>
<a href="/sa/coaches/<?= (int) $coach['id'] ?>/edit" class="btn btn-primary"><i data-lucide="edit-3" style="width:15px;height:15px;vertical-align:middle;margin-left:4px;"></i> تعديل</a>
<form method="POST" action="/sa/coaches/<?= (int) $coach['id'] ?>/toggle" style="display:inline;">
    <?= csrf_field() ?>
    <button type="submit" class="btn btn-outline" onclick="return confirm('<?= (int) $coach['is_active'] ? 'هل أنت متأكد من تعطيل هذا المدرب؟' : 'هل أنت متأكد من تفعيل هذا المدرب؟' ?>');">
        <i data-lucide="<?= (int) $coach['is_active'] ? 'toggle-right' : 'toggle-left' ?>" style="width:15px;height:15px;vertical-align:middle;margin-left:4px;"></i>
        <?= (int) $coach['is_active'] ? 'تعطيل' : 'تفعيل' ?>
    </button>
</form>
<?php endif; ?>
<a href="/sa/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'); ?>

<?php
$isActive = (int) ($coach['is_active'] ?? 0);
?>

<!-- Status Badge -->
<div style="margin-bottom:20px;">
    <?php if ($isActive): ?>
    <span style="display:inline-block;padding:5px 14px;border-radius:10px;font-size:13px;font-weight:600;background:#D1FAE5;color:#065F46;">نشط</span>
    <?php else: ?>
    <span style="display:inline-block;padding:5px 14px;border-radius:10px;font-size:13px;font-weight:600;background:#FEE2E2;color:#DC2626;">معطّل</span>
    <?php endif; ?>
</div>

<!-- 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="user" 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>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">الكود</div>
                <div style="font-weight:600;"><code style="font-size:13px;background:#F3F4F6;padding:3px 8px;border-radius:4px;"><?= e($coach['code'] ?? '-') ?></code></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">الاسم بالعربي</div>
                <div style="font-weight:600;"><?= e($coach['full_name_ar'] ?? '-') ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">الاسم بالإنجليزي</div>
                <div style="font-weight:600;"><?= e($coach['full_name_en'] ?? '-') ?></div>
            </div>
        </div>
        <div style="display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:20px;margin-top:20px;">
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">الرقم القومي</div>
                <div style="direction:ltr;text-align:right;"><?= e($coach['national_id'] ?? '-') ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">الهاتف</div>
                <div style="direction:ltr;text-align:right;"><?= e($coach['phone'] ?? '-') ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">البريد الإلكتروني</div>
                <div style="direction:ltr;text-align:right;"><?= e($coach['email'] ?? '-') ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">تاريخ الميلاد</div>
                <div><?= !empty($coach['date_of_birth']) ? e($coach['date_of_birth']) : '-' ?></div>
            </div>
        </div>
        <div style="display:grid;grid-template-columns:1fr 3fr;gap:20px;margin-top:20px;">
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">النوع</div>
                <div><?php
                    $genderLabels = ['male' => 'ذكر', 'female' => 'أنثى'];
                    echo e($genderLabels[$coach['gender'] ?? ''] ?? '-');
                ?></div>
            </div>
        </div>
    </div>
</div>

<!-- Employment 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="briefcase" style="width:18px;height:18px;color:#059669;"></i>
        <h3 style="margin:0;color:#059669;font-size:15px;">بيانات التوظيف</h3>
    </div>
    <div style="padding:20px;">
        <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;">
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">نوع التوظيف</div>
                <div style="font-weight:600;"><?= e($employmentTypes[$coach['employment_type'] ?? ''] ?? '-') ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">نموذج الدفع</div>
                <div style="font-weight:600;"><?= e($paymentModels[$coach['payment_model'] ?? ''] ?? '-') ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">أقصى عدد مجموعات</div>
                <div style="font-weight:600;"><?= !empty($coach['max_groups']) ? (int) $coach['max_groups'] : '-' ?></div>
            </div>
        </div>
        <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;margin-top:20px;">
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">سعر الساعة</div>
                <div><?= $coach['hourly_rate'] !== null && $coach['hourly_rate'] !== '' ? number_format((float) $coach['hourly_rate'], 2) . ' ج.م' : '-' ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">سعر الحصة</div>
                <div><?= $coach['session_rate'] !== null && $coach['session_rate'] !== '' ? number_format((float) $coach['session_rate'], 2) . ' ج.م' : '-' ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">الراتب الشهري</div>
                <div><?= $coach['monthly_rate'] !== null && $coach['monthly_rate'] !== '' ? number_format((float) $coach['monthly_rate'], 2) . ' ج.م' : '-' ?></div>
            </div>
        </div>
    </div>
</div>

<!-- Disciplines -->
<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="activity" style="width:18px;height:18px;color:#7C3AED;"></i>
        <h3 style="margin:0;color:#7C3AED;font-size:15px;">التخصصات</h3>
    </div>
    <div style="padding:20px;">
        <?php if (!empty($disciplines)): ?>
        <div class="table-responsive">
            <table class="data-table">
                <thead>
                    <tr>
                        <th>التخصص</th>
                        <th>الكود</th>
                        <th>المستوى</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($disciplines as $disc): ?>
                    <tr>
                        <td style="font-weight:600;"><?= e($disc['discipline_name'] ?? '') ?></td>
                        <td><code style="font-size:12px;background:#F3F4F6;padding:2px 6px;border-radius:4px;"><?= e($disc['discipline_code'] ?? '') ?></code></td>
                        <td>
                            <?php if (($disc['specialization_level'] ?? '') === 'primary'): ?>
                            <span style="display:inline-block;padding:3px 10px;border-radius:10px;font-size:11px;font-weight:600;background:#DBEAFE;color:#1D4ED8;">أساسي</span>
                            <?php else: ?>
                            <span style="display:inline-block;padding:3px 10px;border-radius:10px;font-size:11px;font-weight:600;background:#F3F4F6;color:#6B7280;">ثانوي</span>
                            <?php endif; ?>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
        <?php else: ?>
        <div style="text-align:center;padding:20px;color:#9CA3AF;font-size:14px;">
            لا توجد تخصصات مسجلة لهذا المدرب.
        </div>
        <?php endif; ?>
    </div>
</div>

<!-- Bio -->
<?php if (!empty($coach['bio_ar'])): ?>
<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="file-text" style="width:18px;height:18px;color:#6B7280;"></i>
        <h3 style="margin:0;color:#6B7280;font-size:15px;">نبذة</h3>
    </div>
    <div style="padding:20px;">
        <p style="margin:0;white-space:pre-wrap;color:#374151;line-height:1.8;"><?= e($coach['bio_ar']) ?></p>
    </div>
</div>
<?php endif; ?>

<!-- Metadata -->
<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:#9CA3AF;"></i>
        <h3 style="margin:0;color:#9CA3AF;font-size:15px;">معلومات النظام</h3>
    </div>
    <div style="padding:20px;">
        <div style="display:grid;grid-template-columns:1fr 1fr;gap:20px;">
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">تاريخ الإنشاء</div>
                <div style="font-size:13px;"><?= e($coach['created_at'] ?? '-') ?></div>
            </div>
            <div>
                <div style="font-size:12px;color:#6B7280;margin-bottom:4px;">آخر تحديث</div>
                <div style="font-size:13px;"><?= e($coach['updated_at'] ?? '-') ?></div>
            </div>
        </div>
    </div>
</div>

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