<!DOCTYPE html>
<html lang="bn">
<head>
    <meta charset="UTF-8">
    <title>Money Receipt - {{ $payment->receipt_no }}</title>
    <style>
        /* A5 সাইজ সেটআপ */
        @page {
            size: A5;
            margin: 10mm;
        }
        body {
            font-family: 'nikosh', sans-serif;
            margin: 0;
            padding: 0;
            font-size: 12px;
            color: #333;
        }
        .receipt-container {
            width: 100%;
            border: 1px solid #ddd;
            padding: 15px;
            box-sizing: border-box;
        }
        .header {
            text-align: center;
            margin-bottom: 20px;
        }
        .header img {
            width: 60px; /* লোগো সাইজ */
            height: auto;
        }
        .header h2 {
            margin: 5px 0;
            font-size: 18px;
            text-transform: uppercase;
        }
        .header p {
            margin: 0;
            font-size: 11px;
        }
        .receipt-title {
            text-align: center;
            font-weight: bold;
            text-decoration: underline;
            margin: 10px 0;
            font-size: 14px;
        }
        .info-table, .items-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 15px;
        }
        .info-table td {
            padding: 3px 0;
        }
        .items-table th, .items-table td {
            border: 1px solid #444;
            padding: 6px;
            text-align: left;
        }
        .text-right { text-align: right; }
        .footer-sign {
            margin-top: 40px;
            display: flex;
            justify-content: space-between;
        }
        .sign-box {
            border-top: 1px solid #000;
            width: 120px;
            text-align: center;
            padding-top: 5px;
            font-size: 10px;
        }
        @media print {
            .no-print { display: none; }
        }
    </style>
</head>
<body onload="window.print()">

    <div class="receipt-container">
        <div class="header">
            @if($school && $school->logo)
                <img src="{{ asset('uploads/logo/' . $school->logo) }}" alt="Logo">
            @endif
            <h2>{{ $school->school_name ?? 'School Name' }}</h2>
            <p>{{ $school->address ?? 'Address Not Found' }}</p>
        </div>

        <div class="receipt-title">মানি রিসিট (Money Receipt)</div>

        <table class="info-table">
            <tr>
                <td><strong>রশিদ নং:</strong> {{ $payment->receipt_no }}</td>
                <td class="text-right"><strong>তারিখ:</strong> {{ date('d/m/Y', strtotime($payment->payment_date)) }}</td>
            </tr>
            <tr>
                <td><strong>ছাত্রের নাম:</strong> {{ $payment->student_name_en }}</td>
                <td class="text-right"><strong>আইডি:</strong> {{ $payment->admission_no }}</td>
            </tr>
            <tr>
                <td colspan="2"><strong>শ্রেণী:</strong> {{ $payment->class_name }}</td>
            </tr>
        </table>

        <table class="items-table">
            <thead>
                <tr style="background: #f4f4f4;">
                    <th>বিবরণ</th>
                    <th class="text-right">পরিমাণ (টাকা)</th>
                </tr>
            </thead>
            <tbody>
                @if(count($items) > 0)
					@foreach($items as $item)
					<tr>
						<td>{{ $item->type_name }}</td>
						<td class="text-right" style="text-align:right !important;">{{ number_format($item->amount_paid, 2) }}</td>
					</tr>
					@endforeach
				@else
					<tr>
						<td>অ্যাডভান্স পেমেন্ট (Advance Payment)</td>
						<td class="text-right" style="text-align:right !important;">{{ number_format($payment->total_paid, 2) }}</td>
					</tr>
				@endif
            </tbody>
            <tfoot>
                <tr>
                    <th class="text-right">মোট জমা:</th>
                    <th class="text-right" style="text-align:right !important;">{{ number_format($payment->total_paid, 2) }}/-</th>
                </tr>
            </tfoot>
        </table>

        <div class="footer-sign">
            <div class="sign-box">অভিভাবকের স্বাক্ষর</div>
            <div class="sign-box">আদায়কারীর স্বাক্ষর</div>
        </div>
    </div>

    <div class="no-print" style="margin-top: 20px; text-align: center;">
        <button onclick="window.print()" style="padding: 10px 20px; cursor: pointer;">প্রিন্ট করুন</button>
        <button onclick="window.close()" style="padding: 10px 20px; cursor: pointer;">বন্ধ করুন</button>
    </div>

</body>
</html>