@extends('layouts.app')

@section('content')
<div class="container-xxl flex-grow-1 container-p-y">
  <div class="row g-4">
    <div class="col-md-4">
      <div class="card">
        <div class="card-header"><h6 class="mb-0">Request Payout</h6></div>
        <div class="card-body">
          <p class="mb-2">Available balance: <strong>${{ number_format($wallet->balance,2) }}</strong></p>
          <form method="POST" action="{{ route('payout-requests.store') }}" class="row g-2">
            @csrf
            <div class="col-12"><input type="number" step="0.01" min="0.01" name="amount" class="form-control" placeholder="Amount" required></div>
            <div class="col-12"><input type="text" name="bank_name" class="form-control" placeholder="Bank name"></div>
            <div class="col-12"><input type="text" name="account_name" class="form-control" placeholder="Account name"></div>
            <div class="col-12"><input type="text" name="account_number" class="form-control" placeholder="Account number"></div>
            <div class="col-12 d-grid"><button class="btn btn-primary">Submit Request</button></div>
          </form>
        </div>
      </div>
    </div>
    <div class="col-md-8">
      <div class="card">
        <div class="card-header"><h5 class="mb-0">My Payout Requests</h5></div>
        <div class="table-responsive">
          <table class="table">
            <thead><tr><th>Amount</th><th>Status</th><th>Note</th><th>Date</th></tr></thead>
            <tbody>
              @forelse($payoutRequests as $request)
              <tr>
                <td>${{ number_format($request->amount,2) }}</td>
                <td>{{ ucfirst($request->status) }}</td>
                <td>{{ $request->admin_note }}</td>
                <td>{{ $request->created_at->format('Y-m-d H:i') }}</td>
              </tr>
              @empty
              <tr><td colspan="4" class="text-center py-4">No payout requests yet.</td></tr>
              @endforelse
            </tbody>
          </table>
        </div>
        <div class="card-body">{{ $payoutRequests->links() }}</div>
      </div>
    </div>
  </div>
</div>
@endsection
