@extends('backend.layout.master')

@section('content')
<div class="main-content">
    <section class="section">
        <div class="section-header">
            <h1>{{__($pageTitle)}}</h1>
        </div>

        <div class="row">
            <div class="col-12 col-md-12 col-lg-12">
                <div class="card">
                    <div class="card-body text-center">
                        <ul class="list-group">
                            <li class="list-group-item d-flex justify-content-between">
                                <span>{{__('Transaction Id')}}</span>
                                <span>{{$manual->transaction_id}}</span>
                            </li> 

                            <li class="list-group-item d-flex justify-content-between">
                                <span>{{__('Payment Date')}}</span>
                                <span>{{$manual->created_at->format('d F Y')}}</span>
                            </li>

                            {{-- Added check to prevent the foreach error --}}
                            @if($manual->payment_proof && (is_array($manual->payment_proof) || is_object($manual->payment_proof)))
                                @foreach ($manual->payment_proof as $key => $proof)
                                    @if(is_array($proof))
                                        <li class="list-group-item d-flex justify-content-between">
                                            <span>{{__(str_replace('_',' ', ucwords($key)))}}</span>
                                            <span class="text-right">
                                                <img src="{{getFile('manual_payment', $proof['file'])}}" alt="" class="w-50">
                                            </span>
                                        </li>
                                        @continue
                                    @endif

                                    <li class="list-group-item d-flex justify-content-between">
                                        <span>{{__(str_replace('_',' ', ucwords($key)))}}</span>
                                        <span>{{__($proof)}}</span>
                                    </li>
                                @endforeach
                            @else
                                {{-- Fallback message if proof is null or empty --}}
                                <li class="list-group-item text-center py-4">
                                    <p class="text-danger mb-0 font-weight-bold">{{ __('No proof submitted by user') }}</p>
                                </li>
                                

                            @endif
                            
                        </ul>
                                                        <div class="mt-8 flex gap-3">
                            <a href="{{ route('admin.deposit.log') }}" class="flex-1 bg-gray-800 text-white text-center py-3 rounded-xl font-bold hover:bg-gray-700 transition-all">
                                {{ __('Back to Logs') }}
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
@endsection