<?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $policy): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <table class="table" style="table-layout: fixed; width: 100%;">
        <?php
            $collapseId = 'collapse-policy-' . preg_replace('/[^a-zA-Z0-9_]/', '-', $policy['policy']);
            $backColor  = $policy['policy_status'] === 'Approved' ? 'background-color:green;' : 'background-color:red;';
        ?>
        <tr style="color:blue; cursor: pointer;" onclick="togglePolicyCollapse('<?php echo e($collapseId); ?>')">
            <td style="width: 15%;">Policy Name</td>
            <td colspan="5" style="position: relative; width: 85%;">
                <span style="margin-right: 5px;" id="icon-<?php echo e($collapseId); ?>">&#9654;</span>
                <a href="/admin/grade/edit/<?php echo e($policy['grade_id']); ?>" target="_blank" onclick="event.stopPropagation();"><?php echo e($policy['policy_name']); ?></a>
                <span style="position: absolute; top: 0; right: 0; display: flex; align-items: center;">
                    <?php if($policy['policy_status'] === 'Approved' || $policy['eligible_net_loan_amount'] > 0): ?>
                        <span style="margin-right: 10px; color: #333;">Eligible Net Loan Amount: <strong>&#8377;<?php echo e(number_format($policy['eligible_net_loan_amount'])); ?></strong></span>
                    <?php endif; ?>
                    <span style="color: white;<?php echo e($backColor); ?>padding: 10px;"><?php echo e($policy['policy_status']); ?></span>
                </span>
            </td>
        </tr>
        <tbody id="<?php echo e($collapseId); ?>" style="display: none;">
            <tr>
                <th style="width: 15%;">Rule Name</th>
                <th style="width: 20%;">Reason</th>
                <th style="width: 20%;">Against Value</th>
                <th style="width: 15%;">Source Value</th>
                <th style="width: 10%;">Passed</th>
                <th style="width: 20%;">Logs</th>
            </tr>
            <?php $__currentLoopData = $policy['rules']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rule): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr style="<?php echo e($rule['result'] === 'No' ? 'color:red' : ''); ?>">
                    <td style="width: 15%;"><?php echo e($rule['key']); ?></td>
                    <td style="width: 20%;"><?php echo e($rule['reason']); ?></td>
                    <td style="width: 20%;"><?php echo $rule['against_condition']; ?></td>
                    <td style="width: 15%;"><?php echo e($rule['source_value']); ?></td>
                    <td style="width: 10%;"><?php echo e($rule['result']); ?></td>
                    <td style="width: 20%;"><?php echo $rule['logs']; ?></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
    </table>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
