@extends('layouts.aura-main')

@section('main-content')
<div class="max-w-4xl mx-auto pb-20">
    
    <div class="flex justify-between items-center mb-10 border-b border-slate-200 pb-6">
        <div>
            <h1 class="text-xl font-black text-slate-900 uppercase tracking-tighter">{{ auth()->user()->currentCompany->name }}</h1>
            <p class="text-[10px] font-bold text-slate-400 uppercase tracking-[0.3em] mt-1">Statement of Financial Position</p>
        </div>

        <form action="{{ route('reports.balance-sheet') }}" method="GET" class="flex items-center gap-2 print:hidden">
            <div class="flex flex-col">
                <label class="text-[9px] font-black text-slate-400 uppercase">As At Date</label>
                <input type="date" name="end_date" value="{{ $endDate }}" class="border border-slate-300 rounded px-2 py-1 text-[11px] font-bold">
            </div>
            <button type="submit" class="bg-indigo-600 text-white px-4 py-2 mt-4 rounded text-[10px] font-black uppercase hover:bg-indigo-700 transition">Update</button>
        </form>
    </div>

    <div class="bg-white border border-slate-200 shadow-sm p-12 print:p-0 print:border-none">
        
        <div class="text-center mb-12">
            <h2 class="text-sm font-black text-slate-900 uppercase tracking-widest">Statement of Financial Position</h2>
            <p class="text-[10px] font-bold text-slate-400 uppercase mt-1">As at {{ \Carbon\Carbon::parse($endDate)->format('d F Y') }}</p>
        </div>

        <table class="w-full text-[12px]">
            <thead>
                <tr class="text-[9px] font-black uppercase text-slate-400 border-b border-slate-100">
                    <th class="py-3 text-left">Description</th>
                    <th class="py-3 text-right w-24">Notes</th>
                    <th class="py-3 text-right w-40">Amount (ZMW)</th>
                </tr>
            </thead>
            <tbody>
                <tr><td colspan="3" class="pt-6 pb-2 font-black text-slate-900 uppercase text-[11px]">Assets</td></tr>
                
                <tr>
                    <td class="py-3 pl-4 text-slate-600 uppercase text-[10px]">Non-current assets</td>
                    <td class="py-3 text-right text-slate-300 italic">8</td>
                    <td class="py-3 text-right font-mono">{{ number_format($nonCurrentAssets, 2) }}</td>
                </tr>
                <tr>
                    <td class="py-3 pl-4 text-slate-600 uppercase text-[10px]">Current assets</td>
                    <td class="py-3 text-right text-slate-300 italic">9</td>
                    <td class="py-3 text-right font-mono">{{ number_format($currentAssets, 2) }}</td>
                </tr>

                <tr class="bg-slate-50/50">
                    <td class="py-3 font-black text-slate-900 uppercase text-[10px] px-2">Total Assets</td>
                    <td></td>
                    <td class="py-3 text-right font-mono font-black border-t-2 border-slate-900">
                        {{ number_format($totalAssets, 2) }}
                    </td>
                </tr>

                <tr><td colspan="3" class="pt-10 pb-2 font-black text-slate-900 uppercase text-[11px]">Equity and Liabilities</td></tr>
                
                <tr>
                    <td class="py-3 pl-4 text-slate-600 uppercase text-[10px]">Capital and reserves</td>
                    <td class="py-3 text-right text-slate-300 italic">10</td>
                    <td class="py-3 text-right font-mono">{{ number_format($totalEquity, 2) }}</td>
                </tr>

                <tr>
                    <td class="py-3 pl-4 text-slate-600 uppercase text-[10px]">Non-current liabilities</td>
                    <td class="py-3 text-right text-slate-300 italic">11</td>
                    <td class="py-3 text-right font-mono">{{ number_format($nonCurrentLiabilities, 2) }}</td>
                </tr>

                <tr>
                    <td class="py-3 pl-4 text-slate-600 uppercase text-[10px]">Current liabilities</td>
                    <td class="py-3 text-right text-slate-300 italic">12</td>
                    <td class="py-3 text-right font-mono">{{ number_format($currentLiabilities, 2) }}</td>
                </tr>

                <tr>
                    <td class="py-8 font-black text-slate-900 uppercase text-[11px] tracking-widest">Total Equity and Liabilities</td>
                    <td></td>
                    <td class="py-8 text-right font-mono text-lg font-black border-b-4 border-double border-slate-900">
                        {{ number_format($totalEquityAndLiabilities, 2) }}
                    </td>
                </tr>
            </tbody>
        </table>

        <div class="mt-20 grid grid-cols-2 gap-32">
            <div class="text-center">
                <div class="border-b-2 border-slate-900 mb-2"></div>
                <p class="text-[9px] font-black text-slate-900 uppercase">Director</p>
            </div>
            <div class="text-center">
                <div class="border-b-2 border-slate-900 mb-2"></div>
                <p class="text-[9px] font-black text-slate-900 uppercase">Director</p>
            </div>
        </div>
    </div>
</div>
@endsection