@extends('admin.layout')

@section('title', 'Transactions')

@section('content')
<div class="data-table">
  <table>
    <thead>
      <tr>
        <th>User</th>
        <th>Type</th>
        <th>Amount</th>
        <th>Currency</th>
        <th>Recipient</th>
        <th>Status</th>
        <th>Date</th>
      </tr>
    </thead>
    <tbody>
      @forelse ($transactions as $tx)
        <tr>
          <td>{{ $tx->user->name ?? 'N/A' }}</td>
          <td>
            <span class="badge {{ $tx->type === 'credit' ? 'badge-success' : 'badge-danger' }}">
              {{ ucfirst($tx->type) }}
            </span>
          </td>
          <td>€{{ number_format($tx->amount, 2) }}</td>
          <td>{{ $tx->currency }}</td>
          <td>{{ $tx->recipient_name ?? 'N/A' }}</td>
          <td>
            <span class="badge 
              @if($tx->status === 'completed') badge-success
              @elseif($tx->status === 'pending') badge-warning
              @else badge-danger
              @endif">
              {{ ucfirst($tx->status) }}
            </span>
          </td>
          <td>{{ $tx->created_at->format('M d, Y H:i') }}</td>
        </tr>
      @empty
        <tr>
          <td colspan="7" class="empty-state">No transactions found.</td>
        </tr>
      @endforelse
    </tbody>
  </table>
</div>

<div style="margin-top: 24px;">
  {{ $transactions->links() }}
</div>
@endsection
