<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Issued &amp; Void Cheques — Print</title>
    <style>
        * { box-sizing: border-box; }
        body {
            font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
            font-size: 12px;
            color: #111;
            margin: 0;
            padding: 1rem 1.25rem;
        }
        .print-toolbar {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid #e5e7eb;
        }
        .print-toolbar button {
            padding: 0.4rem 0.85rem;
            font-size: 0.875rem;
            border: 1px solid #d1d5db;
            border-radius: 0.375rem;
            background: #fff;
            cursor: pointer;
        }
        .report-header {
            text-align: center;
            margin: 0 0 1.25rem;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid #d1d5db;
        }
        .report-company { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.35rem; }
        .report-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
        .report-period { font-size: 0.875rem; color: #374151; }
        table { width: 100%; border-collapse: collapse; }
        th, td {
            border: 1px solid #d1d5db;
            padding: 0.35rem 0.5rem;
            text-align: left;
            vertical-align: top;
        }
        th { background: #f3f4f6; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
        td.num, .text-end { text-align: right; font-variant-numeric: tabular-nums; }
        .status-issued { color: #0a3622; font-weight: 600; }
        .status-void { color: #842029; font-weight: 600; }
        @media print {
            .print-toolbar { display: none; }
        }
    </style>
</head>
<body>
    @unless($forPdf ?? false)
    <div class="print-toolbar">
        <button type="button" onclick="window.print()">Print</button>
        <button type="button" onclick="window.close()">Close</button>
    </div>
    @endunless

    <div class="report-header">
        <div class="report-company">{{ $companyName }}</div>
        <div class="report-title">Issued &amp; Void Cheques</div>
        <div class="report-period">{{ $filterSummary }}</div>
    </div>

    <table>
        <thead>
            <tr>
                <th>SL</th>
                @foreach($visibleColumns as $columnKey)
                    <th @class(['text-end' => $columnKey === 'amount'])>
                        {{ $columnLabels[$columnKey] ?? ucfirst(str_replace('_', ' ', $columnKey)) }}
                    </th>
                @endforeach
            </tr>
        </thead>
        <tbody>
            @forelse($rows as $row)
            <tr>
                <td>{{ $row['serial'] }}</td>
                @foreach($visibleColumns as $columnKey)
                    <td @class([
                        'text-end' => $columnKey === 'amount',
                        'status-void' => $columnKey === 'status' && $row['status'] === 'void',
                        'status-issued' => $columnKey === 'status' && $row['status'] !== 'void',
                    ])>{{ $row['cells'][$columnKey] }}</td>
                @endforeach
            </tr>
            @empty
            <tr>
                <td colspan="{{ count($visibleColumns) + 1 }}" style="text-align:center;color:#6b7280;padding:1.5rem">No cheques found.</td>
            </tr>
            @endforelse
        </tbody>
    </table>
</body>
</html>
