<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تقييم الأداء<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?><a href="/hr/performance/cycles" class="btn btn-secondary">جميع الدورات</a><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<?php $csl = ['draft'=>'مسودة','active'=>'نشطة','review'=>'تحت المراجعة','closed'=>'مغلقة']; ?>
<?php $csc = ['draft'=>'#FEF3C7;color:#92400E','active'=>'#D1FAE5;color:#065F46','review'=>'#DBEAFE;color:#1E40AF','closed'=>'#E5E7EB;color:#374151']; ?>

<?php if ($activeCycle): ?>
<div class="card" style="margin-bottom:20px;">
    <div style="padding:16px;border-bottom:1px solid #E5E7EB;"><h3 style="margin:0;font-size:16px;display:flex;align-items:center;gap:8px;">الدورة النشطة <span style="display:inline-block;padding:2px 8px;border-radius:9999px;font-size:12px;background:#D1FAE5;color:#065F46;">نشطة</span></h3></div>
    <div style="padding:16px;display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:16px;">
        <div><span style="color:#6B7280;font-size:13px;">اسم الدورة</span><div style="font-weight:600;"><?= e($activeCycle['name_ar']) ?></div></div>
        <div><span style="color:#6B7280;font-size:13px;">النوع</span><div><?= $activeCycle['period_type'] === 'annual' ? 'سنوي' : ($activeCycle['period_type'] === 'semi_annual' ? 'نصف سنوي' : 'ربع سنوي') ?></div></div>
        <div><span style="color:#6B7280;font-size:13px;">الفترة</span><div><?= e($activeCycle['start_date']) ?> - <?= e($activeCycle['end_date']) ?></div></div>
    </div>
    <div style="padding:0 16px 16px;"><a href="/hr/performance/cycles/<?= (int) $activeCycle['id'] ?>" class="btn btn-primary">عرض التقييمات</a></div>
</div>
<?php else: ?>
<div class="card" style="margin-bottom:20px;padding:40px;text-align:center;">
    <div style="color:#9CA3AF;margin-bottom:12px;">لا توجد دورة تقييم نشطة حالياً</div>
    <a href="/hr/performance/cycles" class="btn btn-primary">إنشاء دورة جديدة</a>
</div>
<?php endif; ?>

<?php if (!empty($recentCycles)): ?>
<div class="card">
    <div style="padding:16px;border-bottom:1px solid #E5E7EB;"><h3 style="margin:0;font-size:16px;">آخر الدورات</h3></div>
    <div class="table-responsive">
        <table class="data-table">
            <thead><tr><th>الدورة</th><th>النوع</th><th>الفترة</th><th>الحالة</th><th>إجراءات</th></tr></thead>
            <tbody>
                <?php foreach ($recentCycles as $c): ?>
                <tr>
                    <td style="font-weight:600;"><?= e($c['name_ar']) ?></td>
                    <td><?= $c['period_type'] === 'annual' ? 'سنوي' : ($c['period_type'] === 'semi_annual' ? 'نصف سنوي' : 'ربع سنوي') ?></td>
                    <td><?= e($c['start_date']) ?> - <?= e($c['end_date']) ?></td>
                    <td><span style="display:inline-block;padding:2px 8px;border-radius:9999px;font-size:12px;background:<?= $csc[$c['status']] ?? '#E5E7EB;color:#374151' ?>;"><?= e($csl[$c['status']] ?? $c['status']) ?></span></td>
                    <td><a href="/hr/performance/cycles/<?= (int) $c['id'] ?>" style="color:#2563EB;"><i data-lucide="eye" style="width:16px;height:16px;"></i></a></td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>
<?php endif; ?>
<script>if(typeof lucide!=='undefined')lucide.createIcons();</script>
<?php $__template->endSection(); ?>
