<!DOCTYPE html>
<html lang="bn">
<head>
    <meta charset="UTF-8">
    <title>Invoice - {{ $invoice->invoice_no }}</title>
    <style>
		@font-face {
			font-family: 'SolaimanLipi';
			src: url("{{ asset('fonts/SolaimanLipi.ttf') }}") format('truetype');
			font-weight: normal;
			font-style: normal;
		}

		body {
			font-family: 'SolaimanLipi', Arial, sans-serif !important;
			font-size: 14px;
			-webkit-font-smoothing: antialiased;
			-moz-osx-font-smoothing: grayscale;
		}
        /* A5 সাইজ সেটআপ */
        @page {
            size: A5;
            margin: 10mm;
        }
        body {
            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" style="display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 15px;">
			<div style="display: flex; align-items: center; gap: 15px;">
				@if($school && $school->logo)
					<img src="{{ asset('storage/'.$school->logo) }}" alt="Logo" style="height: 70px; width: auto;">
				@endif
				
				<div style="text-align: left;">
					<h2 style="margin: 0; font-size: 15px; font-weight: 900; text-transform: uppercase;">
						{{ $school->school_name ?? 'স্কুলের নাম পাওয়া যায়নি' }}
					</h2>
					<p style="margin: 2px 0; font-size: 13px; font-weight: bold;">
						{{ $school->address ?? 'ঠিকানা পাওয়া যায়নি' }}
					</p>
					<p style="margin: 0; font-size: 13px;">
						📞 {{ $school->contact_number ?? '' }}
					</p>
				</div>
			</div>
		</div>

		<div style="text-align: center; margin-bottom: 20px;">
			<span style="background: #000; color: #fff; padding: 5px 25px; border-radius: 50px; font-weight: 900; text-transform: uppercase; font-size: 14px; letter-spacing: 1px;">
				মানি রিসিট (Money Receipt)
			</span>
		</div>

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

        <table class="items-table">
            <thead>
                <tr style="background: #f4f4f4;">
                    <th>বিবরণ</th>
                    <th class="text-right">পরিমাণ (টাকা)</th>
                </tr>
            </thead>
            <tbody>
                @foreach($items as $item)
                <tr>
                    <td>{{ $item->type_name }}</td>
                    <td class="text-right" style="text-align:right !important;">{{ number_format($item->paid_amount, 2) }}</td>
                </tr>
                @endforeach
            </tbody>
            <tfoot>
				<tr>
					<th class="text-right">সর্বমোট:</th>
					<th class="text-right" style="text-align:right !important;">{{ number_format($invoice->total_amount, 2) }}/-</th>
				</tr>
				<tr>
					<th class="text-right">জমা:</th>
					<th class="text-right" style="text-align:right !important;">{{ number_format($invoice->paid_amount, 2) }}/-</th>
				</tr>
				<tr>
					<th class="text-right">বকেয়া:</th>
					<th class="text-right text-red-500" style="text-align:right !important;">{{ number_format($invoice->due_amount, 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>