@extends('layouts.app')

@section('title', 'Wallet Transactions')

@section('content')
<div class="space-y-6">
    <div class="flex items-center gap-3">
        <a href="{{ route('wallet.index') }}" class="text-gray-400 hover:text-gray-600">
            <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg>
        </a>
        <div>
            <h1 class="text-2xl font-bold text-gray-900">Wallet Transactions</h1>
            <p class="mt-1 text-sm text-gray-500">View all wallet credit and debit history.</p>
        </div>
    </div>

    <div class="rounded-xl bg-white shadow-sm border border-gray-100 overflow-hidden">
        <table class="min-w-full divide-y divide-gray-100">
            <thead class="bg-gray-50">
                <tr>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Type</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Amount</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Balance After</th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Date</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-gray-50">
                @forelse($transactions as $tx)
                <tr class="hover:bg-gray-50">
                    <td class="px-6 py-4 text-sm text-gray-900">{{ $tx->description }}</td>
                    <td class="px-6 py-4">
                        <span class="inline-flex items-center rounded-full {{ $tx->type === 'credit' ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700' }} px-2 py-1 text-xs font-medium">
                            {{ ucfirst($tx->type) }}
                        </span>
                    </td>
                    <td class="px-6 py-4 text-sm font-semibold {{ $tx->type === 'credit' ? 'text-green-950' : 'text-red-600' }}">
                        {{ $tx->type === 'credit' ? '+' : '-' }}₦{{ number_format($tx->amount, 2) }}
                    </td>
                    <td class="px-6 py-4 text-sm text-gray-900">₦{{ number_format($tx->balance_after, 2) }}</td>
                    <td class="px-6 py-4 text-sm text-gray-500">{{ $tx->created_at->format('M d, Y H:i') }}</td>
                </tr>
                @empty
                <tr>
                    <td colspan="5" class="px-6 py-12 text-center text-sm text-gray-500">No transactions yet.</td>
                </tr>
                @endforelse
            </tbody>
        </table>
        <div class="px-6 py-4">{{ $transactions->links() }}</div>
    </div>
</div>
@endsection
