@extends('layouts.app')

@section('title', $lot->title . ' — Charitable Auction')

@section('content')
<div class="min-h-screen bg-navy-950 text-white">
    <div class="max-w-6xl mx-auto px-6 py-10 grid grid-cols-1 lg:grid-cols-2 gap-10">
        {{-- Image --}}
        <div>
            @if($lot->getFirstMediaUrl('primary'))
                <img src="{{ $lot->getFirstMediaUrl('primary') }}" class="w-full rounded-xl border border-gray-800" alt="{{ $lot->title }}">
            @endif
            <p class="mt-4 text-sm text-gray-400">
                <span class="inline-block bg-green-900/50 text-green-300 text-xs px-2 py-1 rounded">CHARITABLE AUCTION LOT</span>
            </p>
        </div>

        {{-- Details & Bidding --}}
        <div>
            <h1 class="text-3xl font-bold">{{ $lot->title }}</h1>
            <p class="mt-2 text-green-300 text-sm">
                Proceeds from this lot directly support helmet safety research and sports-related internships &amp; entrepreneurship.
            </p>

            @if($lot->ai_analysis)
                <div class="mt-6 grid grid-cols-2 gap-4">
                    <div class="bg-navy-900 p-4 rounded-lg border border-gray-800">
                        <p class="text-xs text-gray-400">AI-Estimated Market Value</p>
                        <p class="text-lg font-semibold text-green-400">
                            ${{ number_format($lot->ai_analysis['comps']['market_value'] ?? 0, 0) }}
                        </p>
                    </div>
                    <div class="bg-navy-900 p-4 rounded-lg border border-gray-800">
                        <p class="text-xs text-gray-400">Suggested Starting Bid</p>
                        <p class="text-lg font-semibold">${{ number_format($lot->starting_bid, 0) }}</p>
                    </div>
                </div>
            @endif

            <div class="mt-6">
                <p class="text-sm text-gray-400">Current High Bid</p>
                <p class="text-4xl font-bold text-green-400">${{ number_format($lot->current_bid, 0) }}</p>
            </div>

            {{-- Livewire Bid Form --}}
            <div class="mt-8">
                @livewire('bid-form', ['lot' => $lot])
            </div>

            <div class="mt-8 text-xs text-gray-500 border-t border-gray-800 pt-4">
                Fair market value of this item is estimated at ${{ number_format($lot->ai_analysis['comps']['market_value'] ?? $lot->starting_bid * 2, 0) }}.
                Under IRS rules, only the amount you pay in excess of fair market value may be deductible as a charitable contribution.
                Winning bidders receive a written acknowledgment stating the amount paid, the stated fair market value, and the deductible portion.
                Please consult your own tax advisor regarding deductibility.
            </div>
        </div>
    </div>
</div>
@endsection
