@extends(template().'layout.master2')

@section('content2')
<div class="min-h-screen flex flex-col items-center py-12 px-4">
    
    <div class="max-w-3xl w-full mb-10 flex justify-between items-center px-2">
        <div class="flex items-center gap-3">
            <div class="w-10 h-10 rounded-xl bg-blue-600/10 flex items-center justify-center text-blue-600">
                <i data-lucide="check-circle-2" class="w-5 h-5"></i>
            </div>
            <h1 class="text-2xl font-black text-slate-900 dark:text-white uppercase tracking-tighter italic">{{ __('Confirm Payout') }}</h1>
        </div>
        <a href="{{ route('user.withdrawMethod') }}" 
           class="flex items-center gap-2 text-[10px] font-black uppercase tracking-widest text-slate-500 hover:text-blue-600 transition-colors">
            <i data-lucide="arrow-left" class="w-4 h-4"></i>
            {{ __('Back') }}
        </a>
    </div>

    <div class="max-w-3xl w-full bg-white dark:bg-slate-900 rounded-[3rem] overflow-hidden shadow-2xl border border-slate-200 dark:border-slate-800/50">
        
        <div class="bg-slate-50 dark:bg-slate-950/50 p-8 border-b border-slate-100 dark:border-slate-800/60 flex items-center justify-between">
            <div class="flex items-center gap-6">
                <div class="h-16 w-16 bg-blue-600 rounded-2xl flex items-center justify-center text-white shadow-lg shadow-blue-600/20">
                    <i data-lucide="shield-check" class="w-8 h-8"></i>
                </div>
                <div>
                    <h2 class="text-xl font-black text-slate-900 dark:text-white uppercase tracking-tighter italic">{{ __($method->name) }}</h2>
                    <div class="flex items-center gap-2 mt-1">
                        <span class="text-[10px] font-black text-slate-400 dark:text-slate-500 uppercase tracking-widest">{{ __('Wallet Balance:') }}</span>
                        <span class="text-xs font-black text-emerald-500 italic">{{ number_format(auth()->user()->balance, 2) }} USD</span>
                    </div>
                </div>
            </div>
        </div>

        <form action="{{ route('user.withdraw.completed') }}" method="POST" class="p-8 md:p-12 space-y-10">
            @csrf
            <input type="hidden" name="method" value="{{ $method->id }}">

            <div class="group">
                <label class="block text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-slate-500 mb-4 ml-1 group-focus-within:text-blue-600 transition-colors">
                    {{ __('Amount to Withdraw') }}
                </label>
                <div class="relative">
                    <input type="number" step="any" name="amount" required
                           class="w-full bg-slate-50 dark:bg-slate-950 border border-slate-200 dark:border-slate-800 rounded-[2rem] py-6 px-8 text-3xl font-black text-slate-900 dark:text-white focus:border-blue-500 focus:ring-0 outline-none transition-all placeholder:text-slate-300 dark:placeholder:text-slate-800"
                           placeholder="0.00">
                    <span class="absolute right-8 top-1/2 -translate-y-1/2 text-slate-400 dark:text-slate-600 font-black text-xl italic tracking-tighter">USD</span>
                </div>
            </div>

            <div class="space-y-6">
                <div class="flex items-center gap-3 mb-2">
                    <div class="h-1 w-8 bg-blue-600 rounded-full"></div>
                    <h3 class="text-xs font-black text-slate-900 dark:text-white uppercase tracking-[0.2em] italic">
                        {{ __('Payout Destination') }}
                    </h3>
                </div>

                <div class="grid grid-cols-1 gap-6">
                    @php 
                        $cleanInstructions = strip_tags($method->withdraw_instruction);
                        $fields = explode(',', $cleanInstructions); 
                    @endphp

                    @foreach($fields as $field)
                        @php $fieldName = trim($field); @endphp
                        @if(!empty($fieldName))
                            <div class="group">
                                <label class="block text-[10px] font-black uppercase tracking-widest text-slate-400 dark:text-slate-500 mb-2 ml-1 group-focus-within:text-blue-600 transition-colors">
                                    {{ $fieldName }}
                                </label>
                                <input type="text" name="details[{{ $fieldName }}]" required
                                       class="w-full bg-slate-50 dark:bg-slate-950 border border-slate-200 dark:border-slate-800 rounded-2xl py-4 px-6 text-sm font-bold text-slate-900 dark:text-white focus:border-blue-500 focus:ring-0 transition-all">
                            </div>
                        @endif
                    @endforeach
                </div>
            </div>

            <div class="pt-10 border-t border-slate-100 dark:border-slate-800/60">
                <div class="bg-rose-500/[0.03] dark:bg-rose-500/[0.02] border border-rose-500/10 rounded-[2rem] p-6 md:p-8">
                    <label class="flex items-center gap-2 text-[10px] font-black uppercase tracking-[0.2em] text-rose-500 mb-4">
                        <i data-lucide="lock" class="w-4 h-4"></i>
                        {{ __('Security Transfer Code') }}
                    </label>
                    <input type="password" name="transfer_code" required
                           class="w-full bg-white dark:bg-slate-950 border border-rose-500/20 rounded-2xl py-4 px-6 text-slate-900 dark:text-white focus:border-rose-500 focus:ring-0 transition-all text-center tracking-[1em] font-black"
                           placeholder="••••••">
                    <div class="flex items-start gap-3 mt-4">
                        <i data-lucide="alert-circle" class="w-4 h-4 text-slate-400 mt-0.5"></i>
                        <p class="text-[9px] text-slate-500 dark:text-slate-400 font-bold uppercase tracking-wider leading-relaxed">
                            {{ __('Verification Required.') }} <span class="text-slate-400">{{ __('Confirm this request with your private transfer code. Contact support to get your unique transfer code.') }}</span>
                        </p>
                    </div>
                </div>
            </div>

            <button type="submit" 
                    class="w-full py-5 bg-blue-600 hover:bg-blue-700 text-white font-black uppercase tracking-[0.3em] text-xs rounded-2xl shadow-xl shadow-blue-600/20 active:scale-[0.98] transition-all flex items-center justify-center gap-3 group">
                {{ __('Submit Withdrawal Request') }}
                <i data-lucide="send" class="w-4 h-4 group-hover:translate-x-1 group-hover:-translate-y-1 transition-transform"></i>
            </button>
        </form>
    </div>
</div>
@endsection