@extends('layouts.admin')

@section('content')
<div class="space-y-6">
    <div class="bg-white p-6 rounded-3xl shadow-sm border border-gray-100 flex justify-between items-center">
        <h3 class="font-black text-xl text-gray-800 italic">📊 আয়-ব্যয় রিপোর্ট</h3>
        <form class="flex items-center gap-3">
            <input type="date" name="from_date" value="{{ $from }}" class="p-2 border rounded-xl text-sm outline-none">
            <span class="text-gray-400">থেকে</span>
            <input type="date" name="to_date" value="{{ $to }}" class="p-2 border rounded-xl text-sm outline-none">
            <button type="submit" class="bg-blue-600 text-white px-6 py-2 rounded-xl font-bold hover:bg-blue-700 transition-all">দেখুন</button>
        </form>
    </div>

    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
        <div class="bg-white rounded-3xl shadow-sm border border-emerald-100 overflow-hidden">
            <div class="p-5 bg-emerald-500 text-white font-black text-center uppercase tracking-widest">আয় (Income)</div>
            <table class="w-full text-left">
                <tbody class="divide-y divide-gray-50">
                    @foreach($income as $in)
                    <tr>
                        <td class="px-6 py-4 font-bold text-gray-600">{{ $in->head_name }}</td>
                        <td class="px-6 py-4 text-right font-black text-emerald-600">{{ number_format($in->total, 2) }} ৳</td>
                    </tr>
                    @endforeach
                </tbody>
                <tfoot class="bg-emerald-50">
                    <tr class="font-black text-emerald-700">
                        <td class="px-6 py-4 uppercase">মোট আয়</td>
                        <td class="px-6 py-4 text-right">{{ number_format($income->sum('total'), 2) }} ৳</td>
                    </tr>
                </tfoot>
            </table>
        </div>

        <div class="bg-white rounded-3xl shadow-sm border border-rose-100 overflow-hidden">
            <div class="p-5 bg-rose-500 text-white font-black text-center uppercase tracking-widest">ব্যয় (Expense)</div>
            <table class="w-full text-left">
                <tbody class="divide-y divide-gray-50">
                    @foreach($expense as $ex)
                    <tr>
                        <td class="px-6 py-4 font-bold text-gray-600">{{ $ex->head_name }}</td>
                        <td class="px-6 py-4 text-right font-black text-rose-600">{{ number_format($ex->total, 2) }} ৳</td>
                    </tr>
                    @endforeach
                </tbody>
                <tfoot class="bg-rose-50">
                    <tr class="font-black text-rose-700">
                        <td class="px-6 py-4 uppercase">মোট ব্যয়</td>
                        <td class="px-6 py-4 text-right">{{ number_format($expense->sum('total'), 2) }} ৳</td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>

    @php $balance = $income->sum('total') - $expense->sum('total'); @endphp
    <div class="p-8 rounded-[2.5rem] {{ $balance >= 0 ? 'bg-emerald-600' : 'bg-rose-600' }} text-white text-center shadow-2xl">
        <h2 class="text-sm font-bold uppercase opacity-80 tracking-widest mb-2">সার্বিক অবস্থা (Balance)</h2>
        <h1 class="text-5xl font-black">{{ number_format($balance, 2) }} ৳</h1>
        <p class="mt-2 font-bold">{{ $balance >= 0 ? 'আপনি লাভে আছেন বাহে!' : 'লস হইছে, হিসাব চেক করেন।' }}</p>
    </div>
</div>
@endsection