{{-- Member Loan Products --}}
<x-app-layout title="Available Loan Products">

    <x-module-hero title="Available Loan Products" description="Choose a loan product to apply for" icon="fa-money-bill-wave">
        <x-slot name="tabs">
            <a href="{{ route('member.dashboard') }}" class="module-hero-tab">
                <i class="fas fa-tachometer-alt"></i> Dashboard
            </a>
            <a href="{{ route('member.loans.index') }}" class="module-hero-tab">
                <i class="fas fa-list"></i> My Loans
            </a>
            <a href="{{ route('member.loans.products') }}" class="module-hero-tab active-tab">
                <i class="fas fa-plus-circle"></i> Apply for Loan
            </a>
            <a href="{{ route('member.contributions') }}" class="module-hero-tab">
                <i class="fas fa-hand-holding-usd"></i> Contributions
            </a>
        </x-slot>
    </x-module-hero>

    <div class="p-6">
        @if($products->count() > 0)
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                @foreach($products as $product)
                    <div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden hover:shadow-md transition-shadow">
                        <div class="p-5 text-white relative" style="background-color: var(--theme-bg-sidebar);">
                            @if($product->is_featured)
                                <span class="absolute top-3 right-3 bg-yellow-400 text-yellow-900 text-xs px-2 py-0.5 rounded-full font-semibold">Featured</span>
                            @endif
                            <h3 class="text-lg font-bold mb-1">{{ $product->name }}</h3>
                            <p class="text-white/70 text-sm">{{ $product->interest_rate_display ?? $product->interest_rate . '% APR' }}</p>
                        </div>
                        <div class="p-5">
                            <p class="text-gray-600 text-sm mb-4 line-clamp-2">{{ $product->description ?? 'Flexible financing solutions tailored to your needs.' }}</p>
                            <div class="space-y-2 mb-4">
                                <div class="flex justify-between text-sm">
                                    <span class="text-gray-500">Amount Range</span>
                                    <span class="font-medium text-gray-900">{{ $product->formatted_amount_range }}</span>
                                </div>
                                <div class="flex justify-between text-sm">
                                    <span class="text-gray-500">Term Range</span>
                                    <span class="font-medium text-gray-900">{{ $product->min_term_months }}-{{ $product->max_term_months }} months</span>
                                </div>
                                <div class="flex justify-between text-sm">
                                    <span class="text-gray-500">Interest Rate</span>
                                    <span class="font-medium text-gray-900">{{ $product->interest_rate_display ?? $product->interest_rate . '%' }}</span>
                                </div>
                            </div>
                            <a href="{{ route('member.loans.apply', $product) }}" class="block text-center px-4 py-2.5 bg-green-600 text-white rounded-lg hover:bg-green-700 transition text-sm font-medium">
                                <i class="fas fa-paper-plane mr-1"></i> Apply Now
                            </a>
                        </div>
                    </div>
                @endforeach
            </div>
        @else
            <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-12 text-center">
                <i class="fas fa-box-open text-5xl text-gray-300 mb-4"></i>
                <h3 class="text-lg font-semibold text-gray-700 mb-2">No Eligible Loan Products</h3>
                <p class="text-gray-500">You are not currently eligible for any loan products. Please contact support for more information.</p>
            </div>
        @endif
    </div>

</x-app-layout>
