@extends('layouts.app')
@section('title', 'Checkout')

@section('content')
<section class="py-16" style="background: linear-gradient(135deg, #0a0a0a 0%, #1a0000 100%);">
    <div class="max-w-3xl mx-auto px-4 text-center">
        <h1 class="font-display text-7xl text-white troll-glow mb-3">CHECKOUT</h1>
        <p class="text-gray-400">Almost time. Fill in your details and proceed to payment.</p>
    </div>
</section>

<section class="max-w-4xl mx-auto px-4 py-12">
    <div class="grid md:grid-cols-5 gap-8">

        {{-- Form --}}
        <div class="md:col-span-3">
            <div class="card-dark rounded-2xl p-8">
                <h2 class="font-display text-3xl text-white mb-6">YOUR DETAILS</h2>
                <form action="{{ route('checkout.process') }}" method="POST" class="space-y-5">
                    @csrf
                    <div>
                        <label class="block text-gray-400 text-sm font-medium mb-2">Full Name <span class="text-tm-red">*</span></label>
                        <input type="text" name="full_name" value="{{ old('full_name') }}" required
                            class="w-full bg-tm-mid border border-tm-border rounded-lg px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-tm-red transition-colors"
                            placeholder="Your full name">
                        @error('full_name')<p class="text-red-500 text-xs mt-1">{{ $message }}</p>@enderror
                    </div>
                    <div>
                        <label class="block text-gray-400 text-sm font-medium mb-2">Email Address <span class="text-tm-red">*</span></label>
                        <input type="email" name="email" value="{{ old('email') }}" required
                            class="w-full bg-tm-mid border border-tm-border rounded-lg px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-tm-red transition-colors"
                            placeholder="your@email.com">
                        <p class="text-gray-600 text-xs mt-1">Order confirmation emails will be sent here.</p>
                        @error('email')<p class="text-red-500 text-xs mt-1">{{ $message }}</p>@enderror
                    </div>
                    <div>
                        <label class="block text-gray-400 text-sm font-medium mb-2">Phone Number <span class="text-tm-red">*</span></label>
                        <input type="tel" name="phone" value="{{ old('phone') }}" required
                            class="w-full bg-tm-mid border border-tm-border rounded-lg px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-tm-red transition-colors"
                            placeholder="+1 (555) 000-0000">
                        @error('phone')<p class="text-red-500 text-xs mt-1">{{ $message }}</p>@enderror
                    </div>

                    <div class="bg-tm-mid rounded-xl p-4 border border-tm-border mt-4">
                        <div class="flex items-center gap-3 mb-2">
                            <span class="text-2xl">{{ $paymentInfo['icon'] }}</span>
                            <h3 class="text-white font-semibold">{{ $paymentInfo['label'] }}</h3>
                        </div>
                        @if($paymentInfo['method'] === 'card2crypto')
                            <p class="text-gray-400 text-sm">After submitting, you will be redirected to our secure Card2Crypto payment page. We accept all major credit cards and cryptocurrency.</p>
                        @elseif($paymentInfo['method'] === 'moonpay')
                            <p class="text-gray-400 text-sm">After submitting, you will be redirected to MoonPay to complete your purchase with a card or bank transfer.</p>
                        @elseif($paymentInfo['method'] === 'crypto')
                            <p class="text-gray-400 text-sm">After submitting, you will receive wallet addresses to send your cryptocurrency payment manually.</p>
                        @else
                            <p class="text-gray-400 text-sm">Your order will be confirmed upon submission.</p>
                        @endif
                    </div>

                    <button type="submit" class="btn-troll w-full text-white py-4 rounded-lg font-bold text-lg mt-2">
                        PROCEED TO PAYMENT →
                    </button>
                </form>
            </div>
        </div>

        {{-- Order summary --}}
        <div class="md:col-span-2">
            <div class="card-dark rounded-2xl p-6">
                <h2 class="font-display text-2xl text-white mb-4">ORDER SUMMARY</h2>
                <div class="space-y-3 mb-4">
                    @foreach($cart as $item)
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-300">{{ $item['name'] }} <span class="text-gray-600">×{{ $item['quantity'] }}</span></span>
                        <span class="text-white font-medium">${{ number_format($item['price'] * $item['quantity'], 2) }}</span>
                    </div>
                    @endforeach
                </div>
                <div class="border-t border-tm-border pt-4">
                    <div class="flex justify-between">
                        <span class="text-gray-300 font-semibold">Total</span>
                        <span class="font-display text-3xl text-tm-red">${{ number_format($total, 2) }}</span>
                    </div>
                </div>
                <a href="{{ route('cart.index') }}" class="block text-center text-gray-500 hover:text-tm-red text-xs mt-4 transition-colors">← Edit Cart</a>
            </div>

            <div class="mt-4 text-center text-gray-600 text-xs leading-relaxed">
                🔒 All payments are processed securely. Your information is 100% anonymous on our end.
            </div>
        </div>

    </div>
</section>
@endsection
