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


@section('content2')



<div class="min-h-screen bg-slate-50 dark:bg-slate-950 pt-12 pb-20 px-4 transition-colors duration-300">
    
    <div class="max-w-6xl mx-auto mb-10 flex flex-col sm:flex-row justify-between items-center gap-6 bg-white dark:bg-slate-900/50 p-6 rounded-[2.5rem] border border-slate-200 dark:border-slate-800/60 shadow-xl backdrop-blur-md">
        <div class="flex items-center gap-4">
            <div class="w-12 h-12 rounded-2xl bg-blue-600/10 flex items-center justify-center text-blue-600">
                <i data-lucide="bar-chart-3" class="w-6 h-6"></i>
            </div>
            <div>
                <h5 class="text-xl font-black text-slate-900 dark:text-white uppercase tracking-tighter italic">{{ __('Active Portfolio') }}</h5>
                <p class="text-slate-500 dark:text-slate-400 text-[10px] font-bold uppercase tracking-widest">{{ __('Track your asset cycles and projected returns') }}</p>
            </div>
        </div>
        <a href="{{ route('user.dashboard') }}" class="group flex items-center gap-2 px-6 py-3 rounded-2xl bg-slate-900 dark:bg-slate-800 text-white hover:bg-blue-600 transition-all active:scale-95 text-[10px] font-black uppercase tracking-[0.2em]">
            <i data-lucide="arrow-left" class="w-4 h-4 group-hover:-translate-x-1 transition-transform"></i> 
            {{ __('Return to Hub') }}
        </a>
    </div>

    <div class="max-w-6xl mx-auto relative bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-[2.5rem] overflow-hidden shadow-2xl transition-all duration-300">
        
        <div class="absolute top-0 left-0 w-full h-[2px] bg-gradient-to-r from-transparent via-blue-500/30 to-transparent"></div>

        <div class="overflow-x-auto">
            <table class="min-w-full border-separate border-spacing-0">
                <thead>
                    <tr class="bg-slate-50/50 dark:bg-slate-950/30">
                        <th class="py-6 px-8 text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-slate-500 border-b border-slate-100 dark:border-slate-800/50 text-left">{{ __('Asset Plan') }}</th>
                        <th class="py-6 px-8 text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-slate-500 border-b border-slate-100 dark:border-slate-800/50 text-left">{{ __('Maturity Progress') }}</th>
                        <th class="py-6 px-8 text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-slate-500 border-b border-slate-100 dark:border-slate-800/50 text-left">{{ __('Net Interest') }}</th>
                        <th class="py-6 px-8 text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-slate-500 border-b border-slate-100 dark:border-slate-800/50 text-left">{{ __('Principal') }}</th>
                        <th class="py-6 px-8 text-[10px] font-black uppercase tracking-[0.2em] text-slate-400 dark:text-slate-500 border-b border-slate-100 dark:border-slate-800/50 text-right">{{ __('Status') }}</th>
                    </tr>
                </thead>

                <tbody class="divide-y divide-slate-100 dark:divide-slate-800/40">
                    @forelse ($payments as $plan)
                        @php 
                            $isPaused = ($plan->payment_status == 1 && is_null($plan->next_payment_date));
                        @endphp
                        <tr class="group hover:bg-slate-50/80 dark:hover:bg-slate-800/20 transition-all duration-300">
                            <td class="py-6 px-8 whitespace-nowrap">
                                <div class="flex items-center gap-4">
                                    <div class="w-10 h-10 rounded-xl {{ $isPaused ? 'bg-amber-500/10 border-amber-500/20' : 'bg-emerald-500/10 border-emerald-500/20' }} border flex items-center justify-center transition-transform group-hover:scale-110">
                                        <i data-lucide="{{ $isPaused ? 'pause-circle' : 'layers' }}" class="w-5 h-5 {{ $isPaused ? 'text-amber-500' : 'text-emerald-500' }}"></i>
                                    </div>
                                    <div>
                                        <span class="block text-sm font-black text-slate-900 dark:text-white tracking-tight uppercase italic">{{ @$plan->plan->plan_name }}</span>
                                        <span class="block text-[9px] text-slate-400 font-bold uppercase tracking-widest mt-0.5">{{ $plan->created_at->format('M d, Y') }}</span>
                                    </div>
                                </div>
                            </td>

                            <td class="py-6 px-8 whitespace-nowrap">
                                <div class="flex flex-col gap-2">
                                    <div class="flex justify-between items-end">
                                        <span class="text-[9px] font-black uppercase tracking-widest {{ $isPaused ? 'text-amber-500' : 'text-slate-400' }}">
                                            {{ $isPaused ? __('System Halt') : __('Cycle Count') }}
                                        </span>
                                        <span class="text-[11px] font-black text-slate-900 dark:text-white font-mono">
                                            @if ($plan->plan->return_for == 1)
                                                {{ $plan->pay_count ?? 0 }} / {{ $plan->plan->how_many_time }}
                                            @else
                                                <span class="text-lg leading-none">∞</span>
                                            @endif
                                        </span>
                                    </div>
                                    <div class="w-40 h-1.5 bg-slate-100 dark:bg-slate-800 rounded-full overflow-hidden">
                                        @php 
                                            $percent = ($plan->plan->return_for == 1) ? (($plan->pay_count ?? 0) / $plan->plan->how_many_time) * 100 : 100;
                                        @endphp
                                        <div class="h-full {{ $isPaused ? 'bg-amber-500' : 'bg-emerald-500 shadow-[0_0_12px_rgba(16,185,129,0.3)]' }} transition-all duration-1000 ease-out" style="width: {{ $percent }}%"></div>
                                    </div>
                                </div>
                            </td>

                            <td class="py-6 px-8 whitespace-nowrap">
                                <span class="text-sm font-black {{ $isPaused ? 'text-amber-500' : 'text-emerald-500' }} font-mono italic">
                                    +{{ number_format($plan->interest_amount, 2) }} <span class="text-[10px] opacity-70">{{ @$general->site_currency }}</span>
                                </span>
                            </td>

                            <td class="py-6 px-8 whitespace-nowrap">
                                <span class="text-sm font-black text-slate-700 dark:text-slate-200 tracking-tighter">
                                    {{ number_format($plan->amount, 2) }} <span class="text-[10px] font-bold text-slate-400 uppercase">{{ @$general->site_currency }}</span>
                                </span>
                            </td>

                            <td class="py-6 px-8 whitespace-nowrap text-right">
                                <div class="flex flex-col items-end gap-1.5">
                                    @if ($isPaused)
                                        <span class="px-3 py-1 rounded-full text-[8px] font-black uppercase tracking-[0.2em] bg-amber-500/10 text-amber-500 border border-amber-500/20 animate-pulse">
                                            {{ __('Halted') }}
                                        </span>
                                        <span class="text-[8px] text-slate-400 font-bold uppercase tracking-widest">{{ __('Awaiting Feed') }}</span>
                                    @elseif ($plan->payment_status == 1)
                                        <span class="px-3 py-1 rounded-full text-[8px] font-black uppercase tracking-[0.2em] bg-emerald-500/10 text-emerald-500 border border-emerald-500/20 group-hover:bg-emerald-500 group-hover:text-white transition-colors">
                                            {{ __('Active') }}
                                        </span>
                                        <span class="text-[8px] text-slate-400 font-bold uppercase tracking-widest">{{ __('Next') }}: {{ $plan->next_payment_date }}</span>
                                    @elseif($plan->payment_status == 2)
                                        <span class="px-3 py-1 rounded-full text-[8px] font-black uppercase tracking-[0.2em] bg-blue-500/10 text-blue-500 border border-blue-500/20">
                                            {{ __('Queued') }}
                                        </span>
                                    @else
                                        <span class="px-3 py-1 rounded-full text-[8px] font-black uppercase tracking-[0.2em] bg-slate-500/10 text-slate-400 border border-slate-500/20">
                                            {{ __('Closed') }}
                                        </span>
                                    @endif
                                </div>
                            </td>
                        </tr>
                    @empty
                        <tr>
                            <td colspan="5" class="py-32 text-center">
                                <div class="flex flex-col items-center">
                                    <div class="w-20 h-20 rounded-[2rem] bg-slate-100 dark:bg-slate-800/50 flex items-center justify-center mb-6">
                                        <i data-lucide="inbox" class="w-10 h-10 text-slate-300 dark:text-slate-600"></i>
                                    </div>
                                    <p class="text-slate-400 dark:text-slate-500 text-[10px] font-black uppercase tracking-[0.3em]">{{ __('No Active Capital Found') }}</p>
                                    <a href="{{ route('user.investmentplan') }}" class="mt-6 text-blue-600 text-[10px] font-black uppercase tracking-widest hover:underline">{{ __('Browse Plans') }} &rarr;</a>
                                </div> 
                            </td>
                        </tr>
                    @endforelse
                </tbody>
            </table>
        </div>
    </div>
</div>
@endsection
