<?php $__template->layout('Layout.main'); ?>

<?php $__template->section('title'); ?>تفاصيل التسوية<?php $__template->endSection(); ?>

<?php $__template->section('content'); ?>
<div style="max-width:700px;margin:0 auto;">
    <div class="card">
        <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;font-weight:600;">
            تسوية: <?= e($settlement['settlement_number']) ?>
        </div>
        <div style="padding:20px;">
            <?php
            $statusColor = match($settlement['status']) {
                'pending'  => '#F59E0B',
                'received' => '#059669',
                'rejected' => '#DC2626',
                default    => '#6B7280',
            };
            $statusLabel = match($settlement['status']) {
                'pending'  => 'في انتظار الاستلام',
                'received' => 'تم الاستلام',
                'rejected' => 'مرفوضة',
                default    => $settlement['status'],
            };
            ?>
            <div style="background:#F9FAFB;border-radius:8px;padding:15px;margin-bottom:15px;">
                <div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;font-size:14px;">
                    <div><span style="color:#6B7280;">الحالة:</span></div>
                    <div><span style="color:<?= $statusColor ?>;font-weight:700;"><?= e($statusLabel) ?></span></div>

                    <div><span style="color:#6B7280;">المبلغ:</span></div>
                    <div style="font-size:20px;font-weight:700;color:#059669;"><?= money($settlement['amount']) ?></div>

                    <div><span style="color:#6B7280;">من:</span></div>
                    <div><?= e($settlement['from_treasury_name'] ?? '—') ?></div>

                    <div><span style="color:#6B7280;">إلى:</span></div>
                    <div><?= e($settlement['to_treasury_name'] ?? '—') ?></div>

                    <div><span style="color:#6B7280;">رقم الوردية:</span></div>
                    <div style="font-family:monospace;"><?= e($settlement['session_number'] ?? '—') ?></div>

                    <div><span style="color:#6B7280;">عدد الإيصالات:</span></div>
                    <div><?= (int) $settlement['receipt_count'] ?></div>

                    <div><span style="color:#6B7280;">أجراها:</span></div>
                    <div><?= e($settlement['settled_by_name'] ?? '—') ?> — <?= e($settlement['settled_at'] ?? '') ?></div>

                    <?php if ($settlement['received_by_name']): ?>
                        <div><span style="color:#6B7280;">استلم بواسطة:</span></div>
                        <div><?= e($settlement['received_by_name']) ?> — <?= e($settlement['received_at'] ?? '') ?></div>
                    <?php endif; ?>

                    <?php if ($settlement['rejection_reason']): ?>
                        <div><span style="color:#6B7280;">سبب الرفض:</span></div>
                        <div style="color:#DC2626;"><?= e($settlement['rejection_reason']) ?></div>
                    <?php endif; ?>
                </div>
            </div>

            <a href="/treasury/settlements" class="btn btn-outline">العودة للقائمة</a>
        </div>
    </div>
</div>
<?php $__template->endSection(); ?>
