<?php
$spouses = $spouses ?? [];
$memberId = $memberId ?? 0;
?>
<?php if (!empty($spouses)): ?>
<table class="data-table">
    <thead>
        <tr><th>#</th><th>الاسم</th><th>الرقم القومي</th><th>تاريخ الميلاد</th><th>السن</th><th>التصنيف</th><th>رسوم</th><th>الحالة</th><th>الإجراءات</th></tr>
    </thead>
    <tbody>
        <?php foreach ($spouses as $s): ?>
        <tr>
            <td><?= (int) $s['spouse_order'] ?></td>
            <td><a href="/members/<?= (int) $memberId ?>/spouses/<?= (int) $s['id'] ?>" style="color:#0D7377;font-weight:600;"><?= e($s['full_name_ar']) ?></a></td>
            <td style="direction:ltr;text-align:right;font-size:13px;"><?= e($s['national_id'] ?? '—') ?></td>
            <td style="font-size:13px;"><?= e($s['date_of_birth']) ?></td>
            <td><?= (int) ($s['age_years'] ?? 0) ?></td>
            <td><?= ($s['classification'] ?? '') === 'working' ? 'عامل' : 'تابع' ?></td>
            <td style="font-weight:600;"><?= money($s['addition_fee'] ?? '0') ?></td>
            <td><span style="color:<?= ($s['status'] ?? '') === 'active' ? '#059669' : '#DC2626' ?>;font-weight:600;">● <?= ($s['status'] ?? '') === 'active' ? 'نشط' : ($s['status'] ?? '') ?></span></td>
            <td>
                <div style="display:flex;gap:5px;">
                    <a href="/members/<?= (int) $memberId ?>/spouses/<?= (int) $s['id'] ?>" class="btn btn-sm btn-outline">عرض</a>
                    <a href="/members/<?= (int) $memberId ?>/spouses/<?= (int) $s['id'] ?>/edit" class="btn btn-sm btn-outline">تعديل</a>
                </div>
            </td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php else: ?>
<p style="color:#6B7280;text-align:center;padding:20px;">لا توجد زوجات مسجلة</p>
<?php endif; ?>