<!DOCTYPE html>
<html lang="bn">
<head>
    <meta charset="UTF-8">
    <title>বকেয়া রিপোর্ট - {{ $company->school_name ?? 'School Name' }}</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;
		}
        body { margin: 0; padding: 20px; }
        .header { text-align: center; margin-bottom: 30px; border-bottom: 2px solid #444; padding-bottom: 10px; }
        .header h2 { margin: 5px 0; text-transform: uppercase; }
        .report-info { display: flex; justify-content: space-between; margin-bottom: 15px; font-size: 14px; }
        table { width: 100%; border-collapse: collapse; margin-top: 10px; }
        th, td { border: 1px solid #ddd; padding: 10px; text-align: left; font-size: 13px; }
        th { bg-color: #f4f4f4; font-weight: bold; }
        .text-right { text-align: right; }
        .footer { margin-top: 50px; text-align: right; font-size: 12px; }
        @media print {
            .no-print { display: none; }
            @page { margin: 0.5cm; }
        }
    </button>
    </style>
</head>
<body onload="window.print()">
    <div class="no-print" style="margin-bottom: 20px;">
        <button onclick="window.print()" style="padding: 10px 20px; cursor: pointer;">প্রিন্ট করুন</button>
    </div>

    <div class="header" style="display: flex; align-items: center; justify-content: center; gap: 20px; border-bottom: 2px solid #444; padding-bottom: 15px; margin-bottom: 25px;">
		@if($company->logo)
			<div class="logo">
				<img src="{{ asset('storage/'.$company->logo) }}" alt="Logo" style=
"height: 80px; width: auto; object-fit: contain;">
			</div>
		@endif

		<div class="school-info" style="text-align: left;">
			<h2 style="margin: 0; font-size: 24px; color: #000; text-transform: 
uppercase; line-height: 1.2;">
				{{ $company->school_name }}
			</h2>
			<p style="margin: 5px 0 0 0; font-size: 14px; color: #555; font-weight: 
bold;">
				{{ $company->address }}
			</p>
			<p style="margin: 2px 0 0 0; font-size: 14px; color: #555;">
				📞 {{ $company->contact_number }}
			</p>
		</div>
	</div>

	<div style="text-align: center; margin-bottom: 20px;">
		<h3 style="background: #f3f4f6; display: inline-block; padding: 6px 20px; 
border-radius: 8px; font-size: 16px; border: 1px solid #e5e7eb; color: #374151;">
			বকেয়া (Due) রিপোর্ট
		</h3>
	</div>

    <div class="report-info">
        <span>তারিখ: {{ date('d-m-Y') }}</span>
        <span>ক্লাস: {{ request('class_name') ?? 'সকল' }}</span>
    </div>

    <table>
        <thead>
            <tr>
                <th>রোল</th>
                <th>ছাত্রের নাম</th>
                <th>ক্লাস</th>
                <th class="text-right">মোট ফি</th>
                <th class="text-right">জমা</th>
                <th class="text-right">বকেয়া</th>
            </tr>
        </thead>
        <tbody>
            @php $totalDue = 0; @endphp
            @foreach($report as $row)
                @php $totalDue += $row->due_amount; @endphp
                <tr>
                    <td>{{ $row->roll_no }}</td>
                    <td>{{ $row->student_name_bn }}</td>
                    <td>{{ $row->class_name }}</td>
                    <td class="text-right">{{ number_format($row->total_amount, 2) }}</td>
                    <td class="text-right">{{ number_format($row->paid_amount, 2) }}</td>
                    <td class="text-right"><strong>{{ number_format($row->due_amount, 2) }}</strong></td>
                </tr>
            @endforeach
        </tbody>
        <tfoot>
            <tr style="background: #f9f9f9;">
                <td colspan="5" class="text-right"><strong>সর্বমোট বকেয়া:</strong></td>
                <td class="text-right"><strong>{{ number_format($totalDue, 2) }} ৳</strong></td>
            </tr>
        </tfoot>
    </table>

    <div class="footer">
        <p>প্রিন্ট টাইম: {{ date('h:i A') }} | জেনারেটেড বাই: {{ auth()->user()->name ?? 'Admin' }}</p>
    </div>
</body>
</html>