<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GL Account Detail</title>
    <style>
        body { font-family: Arial, sans-serif; font-size: 11px; margin: 16px; color: #111; }
        h3, h4 { margin: 0; }
        .line { border-top: 1px solid #888; margin: 7px 0; }
        .section { margin-top: 12px; }
        table { width: 100%; border-collapse: collapse; margin-top: 6px; }
        th, td { border: 1px solid #ddd; padding: 5px; vertical-align: top; }
        th { background: #f2f4f7; text-align: left; }
        .text-right { text-align: right; }
        .text-center { text-align: center; }
    </style>
</head>
<body>
    @include('modules.reports.partials.pdf-company-details')
    <div class="text-center">
        <h3>GL ACCOUNT DETAIL</h3>
    </div>
    <div class="line"></div>
    <div><strong>GL Code:</strong> {{ $glcode }}</div>
    <div><strong>Generated:</strong> {{ now()->format('M j, Y H:i') }}</div>

    <div class="section">
        <table>
            <thead>
                <tr>
                    <th style="width: 14%;">Transaction Date</th>
                    <th style="width: 18%;">Reference</th>
                    <th>Description</th>
                    <th class="text-center" style="width: 8%;">TR</th>
                    <th class="text-right" style="width: 14%;">Amount</th>
                    <th class="text-right" style="width: 14%;">Balance</th>
                </tr>
            </thead>
            <tbody>
                @forelse(($transactions ?? collect()) as $t)
                    <tr>
                        <td>{{ $t['date'] ? \Carbon\Carbon::parse($t['date'])->format('Y-m-d') : '' }}</td>
                        <td>{{ $t['reference'] ?? '' }}</td>
                        <td>{{ $t['description'] ?? '' }}</td>
                        <td class="text-center">{{ $t['trcode'] ?? '' }}</td>
                        <td class="text-right">{{ number_format((float)($t['amount'] ?? 0), 2) }}</td>
                        <td class="text-right">{{ number_format((float)($t['balance_after'] ?? 0), 2) }}</td>
                    </tr>
                @empty
                    <tr><td colspan="6" class="text-center">No transactions found.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</body>
</html>

