<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>سجل تعديلات: <?= e($rule->name_ar) ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/rules" class="btn btn-outline">← العودة</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card">
    <?php if (empty($versions)): ?>
        <div style="padding:40px;text-align:center;color:#6B7280;">لا توجد تعديلات سابقة</div>
    <?php else: ?>
        <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 foreach ($versions as $v): ?>
                    <tr>
                        <td style="text-align:center;font-weight:700;"><?= (int) $v['version_number'] ?></td>
                        <td style="font-size:12px;"><?= e($v['changed_at']) ?></td>
                        <td><?= e($v['changed_by_name'] ?? '—') ?></td>
                        <td style="font-size:11px;direction:ltr;text-align:left;max-width:200px;overflow:hidden;"><code><?= e(mb_substr($v['old_value_json'] ?? '—', 0, 100)) ?></code></td>
                        <td style="font-size:11px;direction:ltr;text-align:left;max-width:200px;overflow:hidden;"><code><?= e(mb_substr($v['new_value_json'], 0, 100)) ?></code></td>
                        <td style="font-size:13px;color:#6B7280;"><?= e($v['change_reason'] ?? '—') ?></td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    <?php endif; ?>
</div>
<?php $__template->endSection(); ?>