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


@section('content2')
<div class="dashboard-body-part">
    <div class="flex items-center justify-between mb-8">
        <div>
            <h5 class="text-xl font-black text-white tracking-tight">{{ __('Transaction History') }}</h5>
            <p class="text-zinc-500 text-xs mt-1">Review your earnings and account adjustments</p>
        </div>
        <a href="{{ route('user.dashboard') }}" class="flex items-center justify-center w-10 h-10 rounded-full bg-zinc-900 border border-zinc-800 text-zinc-400 hover:text-white hover:border-zinc-700 transition-all">
            <i class="bi bi-arrow-left text-lg"></i>
        </a>
    </div>

    <div class="bg-zinc-900/40 border border-zinc-800/60 rounded-3xl p-5 md:p-8 backdrop-blur-sm">
        
        <div class="flex flex-col lg:flex-row lg:items-center justify-between gap-6 mb-8">
            <h5 class="text-zinc-400 font-bold text-sm uppercase tracking-widest">{{ __('Activity Log') }}</h5>

            <form action="" method="get" class="flex flex-wrap items-center gap-3">
                <div class="relative flex-1 min-w-[200px]">
                    <i class="bi bi-calendar4-event absolute left-4 top-1/2 -translate-y-1/2 text-zinc-500 text-sm"></i>
                    <input type="date" name="date" 
                        class="w-full bg-zinc-950 border border-zinc-800 text-zinc-300 rounded-2xl pl-11 pr-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-[#0CA24B]/50 focus:border-[#0CA24B] transition-all">
                </div>
                <button type="submit"
                    class="bg-[#0CA24B] hover:bg-[#0CA24B]/80 text-white font-bold px-6 py-2.5 rounded-2xl transition-all duration-300 text-sm shadow-lg shadow-[#0CA24B]/10 active:scale-95">
                    {{ __('Filter') }}
                </button>
            </form>
        </div>

        <div class="space-y-4">
            @forelse ($interestLogs as $log)
                @php
                    $val = $log->interest_amount ?? $log->amount ?? 0;
                    $isProfit = isset($log->interest_amount);
                    $isNegative = $val < 0;
                @endphp

                <div class="group relative bg-zinc-950/50 border border-zinc-800/50 p-4 rounded-2xl flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 transition-all hover:bg-zinc-900 hover:border-zinc-700">
                    
                    <div class="flex items-center gap-4 flex-1">
                        <div class="h-12 w-12 rounded-2xl {{ $isNegative ? 'bg-red-500/10 text-red-500' : 'bg-emerald-500/10 text-emerald-500' }} border {{ $isNegative ? 'border-red-500/20' : 'border-emerald-500/20' }} flex items-center justify-center shrink-0">
                            @if($isProfit)
                                <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6" />
                                </svg>
                            @else
                                <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                                    <path stroke-linecap="round" stroke-linejoin="round" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                                </svg>
                            @endif
                        </div>

                        <div class="min-w-0">
                            <h4 class="text-white text-sm font-bold tracking-tight">
                                {{ $isProfit ? ($log->payment->plan->plan_name ?? 'Investment Profit') : ($log->remark ?? 'Wallet Adjustment') }}
                            </h4>
                            <div class="flex items-center gap-2 mt-1">
                                <span class="text-zinc-500 text-[10px] font-bold uppercase tracking-widest">{{ $isProfit ? 'TRX' : 'SYS' }}-{{ $log->id }}</span>
                                <span class="h-1 w-1 rounded-full bg-zinc-700"></span>
                                <span class="text-zinc-500 text-[10px] font-medium">{{ $log->created_at->format('M d, Y • H:i') }}</span>
                            </div>
                        </div>
                    </div>

                    <div class="flex flex-row sm:flex-col items-center sm:items-end justify-between w-full sm:w-auto gap-2">
                        <div class="{{ $isNegative ? 'text-red-400' : 'text-emerald-400' }} text-lg font-black tracking-tighter">
                            {{ $isNegative ? '-' : '+' }}{{ @Auth::user()->currency }}{{ number_format(abs($val), 2) }}
                        </div>
                        <div class="px-2.5 py-1 rounded-lg {{ $isNegative ? 'bg-red-500/10 text-red-500 border-red-500/20' : 'bg-emerald-500/10 text-emerald-500 border-emerald-500/20' }} border text-[9px] font-black uppercase">
                            {{ $isNegative ? 'Debit' : 'Credit' }}
                        </div>
                    </div>
                </div>
            @empty
                <div class="bg-zinc-950/30 border border-dashed border-zinc-800 rounded-3xl py-16 text-center">
                    <div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-zinc-900 mb-4">
                        <i class="bi bi-stack text-zinc-700 text-2xl"></i>
                    </div>
                    <p class="text-zinc-500 text-sm font-medium">{{ __('No transactions found for this period.') }}</p>
                </div>
            @endforelse
        </div>

        @if(method_exists($interestLogs, 'links'))
            <div class="mt-8">
                {{ $interestLogs->links() }}
            </div>
        @endif
    </div>
</div>
@endsection
