<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تقرير القوى العاملة<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?><a href="/hr/reports" class="btn btn-secondary">رجوع</a><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px;margin-bottom:20px;">
    <div class="card" style="padding:16px;text-align:center;"><div style="font-size:13px;color:#6B7280;">إجمالي الموظفين</div><div style="font-size:24px;font-weight:700;"><?= (int) ($totals['total'] ?? 0) ?></div></div>
    <div class="card" style="padding:16px;text-align:center;"><div style="font-size:13px;color:#6B7280;">ذكور</div><div style="font-size:24px;font-weight:700;color:#2563EB;"><?= (int) ($totals['male_count'] ?? 0) ?></div></div>
    <div class="card" style="padding:16px;text-align:center;"><div style="font-size:13px;color:#6B7280;">إناث</div><div style="font-size:24px;font-weight:700;color:#DB2777;"><?= (int) ($totals['female_count'] ?? 0) ?></div></div>
    <div class="card" style="padding:16px;text-align:center;"><div style="font-size:13px;color:#6B7280;">دوام كامل</div><div style="font-size:24px;font-weight:700;color:#059669;"><?= (int) ($totals['full_time'] ?? 0) ?></div></div>
    <div class="card" style="padding:16px;text-align:center;"><div style="font-size:13px;color:#6B7280;">دوام جزئي</div><div style="font-size:24px;font-weight:700;color:#D97706;"><?= (int) ($totals['part_time'] ?? 0) ?></div></div>
</div>
<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><th>دوام جزئي</th></tr></thead>
            <tbody>
                <?php if (empty($byDepartment)): ?>
                <tr><td colspan="6" style="text-align:center;padding:40px;color:#9CA3AF;">لا توجد بيانات</td></tr>
                <?php else: ?>
                <?php foreach ($byDepartment as $d): ?>
                <tr>
                    <td style="font-weight:600;"><?= e($d['department_name'] ?? 'غير محدد') ?></td>
                    <td style="font-weight:700;"><?= (int) $d['total'] ?></td>
                    <td><?= (int) $d['male_count'] ?></td>
                    <td><?= (int) $d['female_count'] ?></td>
                    <td><?= (int) $d['full_time'] ?></td>
                    <td><?= (int) $d['part_time'] ?></td>
                </tr>
                <?php endforeach; ?>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__template->endSection(); ?>
