@extends('layouts.admin')
@section('title', 'Withdrawal Logs')
@section('content')
<div class="page-header"><h1>Withdrawal Logs</h1><p>Approve or reject withdrawal requests</p></div>

<div class="md-card">
    <div class="table-wrap">
        <table class="md-table md-table-light">
            <thead><tr><th>ID</th><th>User</th><th>Network</th><th>Address</th><th>Amount</th><th>Status</th><th>Date</th><th>Actions</th></tr></thead>
            <tbody>
                @forelse($withdrawals as $w)
                <tr>
                    <td>{{ $w->id }}</td>
                    <td>{{ $w->user->name }}</td>
                    <td>{{ $w->network }}</td>
                    <td style="max-width:160px;overflow:hidden;text-overflow:ellipsis">{{ $w->wallet_address }}</td>
                    <td>${{ number_format($w->amount, 2) }}</td>
                    <td><span class="badge {{ $w->status->badgeClass() }}">{{ $w->status->label() }}</span></td>
                    <td>{{ $w->created_at->format('Y-m-d H:i') }}</td>
                    <td>
                        @if($w->status === \App\Enums\RecordStatus::Pending)
                        <div class="action-group">
                            <form method="POST" action="{{ route('admin.withdrawals.approve', $w) }}">@csrf<button class="md-btn md-btn-filled md-btn-sm">Approve</button></form>
                            <form method="POST" action="{{ route('admin.withdrawals.reject', $w) }}">@csrf<button class="md-btn md-btn-danger md-btn-sm">Reject</button></form>
                        </div>
                        @else No actions @endif
                    </td>
                </tr>
                @empty
                <tr><td colspan="8" style="text-align:center;padding:2rem">No withdrawals</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
    <div style="padding:1rem">{{ $withdrawals->links() }}</div>
</div>
@endsection
