<div class="space-y-6" x-data="{ msgs: @js(['download' => __('invoices.download_toast')]) }">
    <div class="animate-rise">
        <h1 class="text-2xl font-bold tracking-tight text-ink">{{ __('invoices.title') }}</h1>
        <p class="mt-1 text-sm text-muted">{{ __('invoices.subtitle') }}</p>
    </div>

    <div class="grid grid-cols-1 gap-6 lg:grid-cols-[1fr_320px] lg:items-start">
        <div class="overflow-hidden rounded-lg border border-line bg-surface shadow-xs animate-rise [animation-delay:60ms]">
            <div class="overflow-x-auto">
                <table class="w-full text-sm">
                    <thead>
                        <tr class="border-b border-line bg-surface-2 text-left text-xs font-semibold text-muted">
                            <th class="px-4 py-3 font-semibold">{{ __('invoices.col_no') }}</th>
                            <th class="px-4 py-3 font-semibold">{{ __('invoices.col_date') }}</th>
                            <th class="px-4 py-3 font-semibold">{{ __('invoices.col_amount') }}</th>
                            <th class="px-4 py-3 font-semibold">{{ __('invoices.col_status') }}</th>
                            <th class="px-4 py-3"></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($rows as $r)
                            <tr class="border-b border-line last:border-0 hover:bg-surface-hover">
                                <td class="px-4 py-3 font-mono text-xs text-body">{{ $r['no'] }}</td>
                                <td class="px-4 py-3 text-body">{{ $r['date'] }}</td>
                                <td class="px-4 py-3 font-mono text-body">{{ $r['amount'] }}</td>
                                <td class="px-4 py-3"><x-ui.badge status="active">{{ __('invoices.paid') }}</x-ui.badge></td>
                                <td class="px-4 py-3 text-right"><x-ui.button variant="ghost" size="sm" @click="$dispatch('notify', { message: msgs.download })"><x-ui.icon name="download" class="size-4" />{{ __('invoices.pdf') }}</x-ui.button></td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>

        <div class="flex flex-col gap-6">
            <div class="rounded-lg border border-accent-border bg-accent-subtle p-5 shadow-xs animate-rise [animation-delay:120ms]">
                <p class="text-xs font-semibold text-muted">{{ __('invoices.next_charge') }}</p>
                <p class="mt-1 font-mono text-2xl font-semibold text-ink">{{ $nextAmount }}</p>
                <p class="mt-1 text-sm text-muted">{{ __('invoices.on_date', ['date' => $nextCharge]) }}</p>
            </div>
            <div class="rounded-lg border border-line bg-surface p-5 shadow-xs animate-rise [animation-delay:180ms]">
                <h2 class="font-semibold text-ink">{{ __('invoices.spend') }}</h2>
                <div class="mt-3 h-48" wire:ignore>
                    <x-ui.chart :config="$spendChart" class="h-48" :label="__('invoices.spend')" />
                </div>
            </div>
        </div>
    </div>
</div>
