<!DOCTYPE html>
<html lang="bn">
<head>
    <meta charset="UTF-8">
    <title>Admin - Withdraw #{{ $withdraw->id }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        :root { --primary:#e53935; --bg:#f5f5f5; }
        * { box-sizing:border-box;margin:0;padding:0; }
        body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:var(--bg); }
        .topbar{
            background:var(--primary);
            color:#fff;
            padding:12px 20px;
            display:flex;
            align-items:center;
            justify-content:space-between;
        }
        .topbar a{ color:#fff;text-decoration:none;font-size:13px; }
        .container{ max-width:800px;margin:20px auto 40px;padding:0 12px; }
        .card{ background:#fff;border-radius:12px;padding:16px 18px 22px;box-shadow:0 4px 12px rgba(0,0,0,.06); }
        .card-title{ font-weight:600;margin-bottom:10px; }
        .row{ display:flex;justify-content:space-between;margin-bottom:6px;font-size:14px; }
        .label{ color:#666; }
        .value{ font-weight:500; }
        .badge{ display:inline-block;padding:3px 8px;border-radius:999px;font-size:11px; }
        .badge-pending{ background:#fff8e1;color:#f9a825; }
        .badge-approved{ background:#e8f5e9;color:#2e7d32; }
        .badge-rejected{ background:#ffebee;color:#c62828; }
        .btn{ border:none;border-radius:999px;padding:7px 12px;font-size:13px;cursor:pointer;margin-right:6px; }
        .btn-approve{ background:#2e7d32;color:#fff; }
        .btn-reject{ background:#c62828;color:#fff; }
        .flash{ background:#e8f5e9;color:#2e7d32;padding:8px 12px;border-radius:8px;font-size:13px;margin-bottom:10px; }
        .input{ width:100%;padding:8px 10px;border-radius:8px;border:1px solid #ddd;font-size:14px; }
        .small-label{ font-size:13px;margin-top:10px;margin-bottom:4px; }
    </style>
</head>
<body>

@php
    $badgeClass = 'badge-pending';
    if ($withdraw->status === 'approved') $badgeClass = 'badge-approved';
    elseif ($withdraw->status === 'rejected') $badgeClass = 'badge-rejected';
@endphp

<div class="topbar">
    <div><a href="{{ route('admin.withdraws.index') }}">← Back</a></div>
    <div>Withdraw #{{ $withdraw->id }}</div>
    <div>
        <span class="badge {{ $badgeClass }}">{{ ucfirst($withdraw->status) }}</span>
    </div>
</div>

<div class="container">
    <div class="card">
        @if(session('success'))
            <div class="flash">{{ session('success') }}</div>
        @endif

        <div class="card-title">Withdraw Details</div>

        <div class="row">
            <div class="label">User:</div>
            <div class="value">{{ optional($withdraw->user)->name }} (ID: {{ optional($withdraw->user)->id }})</div>
        </div>
        <div class="row">
            <div class="label">Phone:</div>
            <div class="value">{{ optional($withdraw->user)->phone }}</div>
        </div>
        <div class="row">
            <div class="label">Method:</div>
            <div class="value">{{ strtoupper($withdraw->method) }}</div>
        </div>
        <div class="row">
            <div class="label">Account Number:</div>
            <div class="value">{{ $withdraw->account_number }}</div>
        </div>
        <div class="row">
            <div class="label">Amount:</div>
            <div class="value">৳ {{ number_format($withdraw->amount) }}</div>
        </div>
        <div class="row">
            <div class="label">Requested At:</div>
            <div class="value">{{ $withdraw->created_at->format('d M Y H:i') }}</div>
        </div>
        @if($withdraw->trx_id)
            <div class="row">
                <div class="label">TRX ID:</div>
                <div class="value">{{ $withdraw->trx_id }}</div>
            </div>
        @endif

        @if($withdraw->status === 'pending')
            <hr style="margin:14px 0; border:none;border-top:1px solid #eee;">

            <form action="{{ route('admin.withdraws.approve', $withdraw) }}" method="POST" style="margin-bottom:8px;">
                @csrf
                <div class="small-label">TRX ID (optional, payment পাঠানোর পর দিতে পারো)</div>
                <input type="text" name="trx_id" class="input" value="{{ old('trx_id', $withdraw->trx_id) }}" placeholder="e.g. TX12345XYZ">
                <button type="submit" class="btn btn-approve" style="margin-top:8px;">Approve Withdraw</button>
            </form>

            <form action="{{ route('admin.withdraws.reject', $withdraw) }}" method="POST">
                @csrf
                <button type="submit" class="btn btn-reject">Reject & Return Balance</button>
            </form>
        @endif
    </div>
</div>

</body>
</html>
