@extends('layouts.app')
@section('title', "Voucher {$voucher->voucher_no}")
@section('breadcrumb')
    @include('components.breadcrumb', ['items' => ['Vouchers' => route('vouchers.index'), $voucher->voucher_no => null]])
@endsection
@section('content')
<div class="max-w-3xl mx-auto space-y-6">
    <div class="flex justify-between">
        <div>
            <h1 class="text-2xl font-bold">{{ $voucher->voucher_no }}</h1>
            <p class="text-sm text-slate-500">{{ ucfirst($voucher->type) }} on {{ $voucher->voucher_date->format('d M Y') }}</p>
        </div>
        <x-badge :variant="$voucher->type === 'receipt' ? 'success' : 'danger'" class="text-base">{{ ucfirst($voucher->type) }}</x-badge>
    </div>
    <x-card :title="ucfirst($voucher->type) . ' Details'">
        <dl class="grid grid-cols-2 gap-4 text-sm">
            <div><dt class="text-slate-500">Date</dt><dd class="font-semibold">{{ $voucher->voucher_date->format('d M Y') }}</dd></div>
            <div><dt class="text-slate-500">Party</dt><dd class="font-semibold">{{ $voucher->party->name ?? '—' }}</dd></div>
            <div><dt class="text-slate-500">Account</dt><dd class="font-semibold">{{ $voucher->account->name ?? '—' }}</dd></div>
            <div><dt class="text-slate-500">Mode</dt><dd class="font-semibold">{{ ucfirst($voucher->mode ?? 'Cash') }}</dd></div>
            <div><dt class="text-slate-500">Cheque No</dt><dd class="font-semibold">{{ $voucher->cheque_no ?? '—' }}</dd></div>
            <div><dt class="text-slate-500">Cheque Date</dt><dd class="font-semibold">{{ $voucher->cheque_date?->format('d M Y') ?? '—' }}</dd></div>
            <div><dt class="text-slate-500">Description</dt><dd class="font-semibold">{{ $voucher->description ?? '—' }}</dd></div>
            <div><dt class="text-slate-500">Created By</dt><dd class="font-semibold">{{ $voucher->creator->name ?? 'System' }}</dd></div>
        </dl>
        <div class="mt-4 pt-4 border-t border-slate-200 text-right">
            <p class="text-3xl font-black text-{{ $voucher->type === 'receipt' ? 'emerald' : 'rose' }}-600">৳{{ number_format($voucher->amount) }}</p>
        </div>
    </x-card>
    <form action="{{ route('vouchers.destroy', $voucher->id) }}" method="POST" onsubmit="return confirm('Delete this voucher?')">
        @csrf @method('DELETE')
        <x-button variant="danger" icon="trash-2" type="submit">Delete Voucher</x-button>
    </form>
</div>
@endsection
