<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تسجيل حالة وفاة — <?= e($member['full_name_ar']) ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<form method="POST" action="/death/store/<?= (int) $member['id'] ?>">
    <?= csrf_field() ?>
    <div class="card" style="padding:20px;margin-bottom:20px;">
        <div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;">
            <div class="form-group">
                <label class="form-label">المتوفى <span style="color:#DC2626;">*</span></label>
                <select name="deceased_type" class="form-select" required>
                    <option value="">-- اختر --</option>
                    <option value="primary_member">العضو الرئيسي (<?= e($member['full_name_ar']) ?>)</option>
                    <?php foreach ($spouses as $s): ?><option value="spouse" data-spouse="<?= (int) $s['id'] ?>">الزوج/ة (<?= e($s['full_name_ar']) ?>)</option><?php endforeach; ?>
                </select>
            </div>
            <div class="form-group"><label class="form-label">تاريخ الوفاة <span style="color:#DC2626;">*</span></label><input type="date" name="death_date" class="form-input" required max="<?= e(date('Y-m-d')) ?>"></div>
            <div class="form-group"><label class="form-label">رقم شهادة الوفاة</label><input type="text" name="death_certificate_number" class="form-input"></div>
            <?php if (!empty($spouses)): ?>
            <div class="form-group"><label class="form-label">الزوج/ة (لنقل العضوية)</label>
                <select name="spouse_id" class="form-select"><option value="">-- اختر --</option>
                <?php foreach ($spouses as $s): ?><option value="<?= (int) $s['id'] ?>"><?= e($s['full_name_ar']) ?></option><?php endforeach; ?>
                </select>
            </div>
            <?php endif; ?>
            <div class="form-group" style="grid-column:1/-1;"><label class="form-label">ملاحظات</label><textarea name="notes" class="form-textarea" rows="3"></textarea></div>
        </div>
    </div>
    <button type="submit" class="btn btn-primary">تسجيل حالة الوفاة</button>
    <a href="/members/<?= (int) $member['id'] ?>" class="btn btn-outline">إلغاء</a>
</form>
<?php $__template->endSection(); ?>