<?php $this->start('body');
    $cats = $this->data['categories'] ?? [];
?>

<div class="d-flex align-items-center justify-content-between mb-3">
    <h5 class="mb-0" style="font-weight:600;color:#334155;"><i class="fas fa-tags me-2" style="color:#7A8BA1;"></i>Asset Categories</h5>
    <a href="<?= PROOT; ?>Assets" class="btn btn-sm" style="background:#F8FAFC;border:1px solid #E2E8F0;color:#334155;"><i class="fas fa-arrow-left me-1"></i>Back to register</a>
</div>

<div class="card border-0 shadow-sm">
    <div class="card-header bg-white" style="border-bottom:1px solid #E2E8F0;">
        <strong style="color:#334155;">Categories drive default depreciation life and the COAs each posting hits.</strong>
    </div>
    <div class="table-responsive">
        <table class="table table-sm mb-0 align-middle">
            <thead style="background:#F1F5F9;">
                <tr>
                    <th style="color:#334155;">Name</th>
                    <th style="color:#334155;">Asset COA</th>
                    <th style="color:#334155;">Acc. depreciation COA</th>
                    <th style="color:#334155;">Depreciation expense COA</th>
                    <th class="text-end" style="color:#334155;">Default life</th>
                    <th style="color:#334155;">Method</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($cats as $c): ?>
                    <tr>
                        <td style="color:#334155;font-weight:500;"><?= htmlspecialchars($c['name']); ?></td>
                        <td class="text-muted small" style="color:#64748B;"><?= htmlspecialchars((string)$c['asset_coa_code']); ?></td>
                        <td class="text-muted small" style="color:#64748B;"><?= htmlspecialchars((string)$c['accdep_coa_code']); ?></td>
                        <td class="text-muted small" style="color:#64748B;"><?= htmlspecialchars((string)$c['depexp_coa_code']); ?></td>
                        <td class="text-end" style="color:#334155;"><?= (int)$c['default_useful_life_months']; ?> months</td>
                        <td><span class="badge" style="background:#E2E8F0;color:#334155;font-size:.62rem;text-transform:capitalize;"><?= $c['default_depreciation_method'] === 'RB' ? 'Reducing balance' : 'Straight-line'; ?></span></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>

<?php $this->end(); ?>
