<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>📊 Transactions – Excel style</title>
    <style>
        /* ===== EXCEL‑LIKE PRINT STYLES ===== */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Calibri', 'Arial', 'Helvetica', sans-serif;
            background: white;
            color: #1e1e1e;
            font-size: 10.5pt;
            line-height: 1.3;
            margin: 0.8in 0.6in;
        }

        .print-wrap {
            max-width: 1200px;
            margin: 0 auto;
        }

        /* ----- header (company) ----- */
        .company-header {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-bottom: 25px;
            border-bottom: 2px solid #4f4f4f;
            padding-bottom: 12px;
        }
        .logo-placeholder {
            width: 70px;
            height: 70px;
            background: #f3f3f3;
            border: 1px solid #aaa;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20pt;
            color: #2b5797;
            font-weight: 600;
        }
        .company-details {
            flex: 1;
        }
        .company-name {
            font-size: 22pt;
            font-weight: 600;
            letter-spacing: 0.5px;
            color: #1e3a5f;
        }
        .report-title {
            font-size: 14pt;
            color: #2e2e2e;
            margin-top: 4px;
        }
        .print-date {
            font-size: 9pt;
            color: #5e5e5e;
            margin-top: 4px;
        }

        /* ----- spreadsheet tables ----- */
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 12px 0 8px;
            table-layout: fixed;
            border: 1px solid #a0a0a0;
        }
        th, td {
            border: 0.5px solid #b0b0b0;
            padding: 6px 8px;
            vertical-align: top;
        }
        th {
            background-color: #e4e4e4;
            font-weight: 600;
            text-align: center;
            font-size: 10pt;
            color: #1e1e1e;
            border-bottom: 1px solid #7f7f7f;
        }
        td {
            background-color: white;
        }
        tbody tr:nth-child(even) td {
            background-color: #fafafa;
        }
        .text-end {
            text-align: right;
        }
        .text-success { color: #006100; font-weight: 500; }
        .text-danger  { color: #9c0006; font-weight: 500; }

        /* section headings */
        .section-title {
            font-size: 16pt;
            font-weight: 600;
            margin: 30px 0 6px;
            border-bottom: 2px solid #4f4f4f;
            padding-bottom: 4px;
            color: #1e3a5f;
            clear: both;
        }

        /* summary stats as a compact two‑cell table */
        .stats-summary {
            width: 60%;
            min-width: 400px;
            margin: 15px 0;
        }
        .stats-summary td {
            text-align: center;
            font-weight: 600;
            background: #f8f8f8;
        }
        .stats-summary td p {
            font-size: 9pt;
            font-weight: 400;
            color: #444;
            margin: 5px 0 0;
        }

        /* footer */
        .company-footer {
            margin-top: 45px;
            border-top: 2px solid #4f4f4f;
            padding-top: 12px;
            font-size: 9.5pt;
            text-align: center;
            color: #2e2e2e;
        }
        .company-address {
            line-height: 1.5;
        }

        @media print {
            body { margin: 0.5in; }
        }
    </style>
</head>
<body>
<div class="print-wrap">

    <!-- ========== SUMMARY AS TWO‑CELL TABLE ========= -->
    <div class="section-title">💰 INCOME & EXPENSE SUMMARY</div>
    <table class="stats-summary">
        <tr>
            <td><span class="text-success">৳{{ number_format($totalIncome, 2) }}</span><p>Total Income</p></td>
            <td><span class="text-danger">৳{{ number_format($totalExpense, 2) }}</span><p>Total Expenses</p></td>
        </tr>
    </table>

    <!-- ========== TRANSACTIONS TABLE ========= -->
    <div class="section-title">📋 TRANSACTION LIST</div>
    <table>
        <thead>
            <tr>
                <th style="width: 12%">Date</th>
                <th style="width: 10%">Type</th>
                <th style="width: 15%" class="text-end">Amount (৳)</th>
                <th style="width: 15%">Payment Method</th>
                <th style="width: 48%">Details / Description</th>
            </tr>
        </thead>
        <tbody>
            @forelse($transactions as $t)
                <tr>
                    <td>{{ $t->date->format('M d, Y') }}</td>
                    <td>
                        @if($t->type == 'income')
                            <span class="badge" >Income</span>
                        @else
                            <span class="badge">Expense</span>
                        @endif
                    </td>
                    <td class="text-end {{ $t->type == 'income' ? 'text-success' : 'text-danger' }}">
                        {{ number_format($t->amount, 2) }}
                    </td>
                    <td>{{ ucfirst($t->payment_method) }}</td>
                    <td>{{ $t->details ?? '-' }}</td>
                </tr>
            @empty
                <tr>
                    <td colspan="5" style="text-align:center;">No transactions found for the selected period.</td>
                </tr>
            @endforelse
        </tbody>
    </table>

    <!-- ========== FOOTER WITH COMPANY ADDRESS ========= -->
    <div class="company-footer">
        <div class="company-address">
            {{ $companyAddress ?? '123 Business Street, Suite 100, Dhaka – 1205, Bangladesh' }}<br>
            <span style="font-size:9pt;">{{ $companyEmail ?? 'info@yourcompany.com' }} | {{ $companyPhone ?? '+880 2 1234 5678' }}</span>
        </div>
        <div style="margin-top:8px; font-size:8.5pt;">Printed from Accounting – Excel‑style transaction report</div>
    </div>

</div><!-- .print-wrap -->

<script>
    window.onload = function() { window.print(); };
</script>
</body>
</html>

