@extends('layouts.app')

@section('title', 'Track Your Order')

@section('content')
    <!-- Hero Section -->
    <div class="text-center mb-12 fade-in">
        <h1 class="text-3xl sm:text-4xl font-bold text-white mb-2">Track Your Order</h1>
        <p class="text-white">Easily find your order status</p>
        <div class="mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-xl bg-gray-100 text-gray-700 text-sm shadow-sm">
            <i class="fas fa-phone-alt text-primary-500"></i>
            <span>Customer Support: <strong>0321-4241864</strong></span>
        </div>
    </div>

    <!-- Search Options -->
    <div class="grid md:grid-cols-2 gap-6 lg:gap-8 mb-16 max-w-4xl mx-auto">
        {{-- Search by Order No --}}
        <div class="rounded-2xl bg-gradient-to-br from-amber-100 to-amber-50 p-6 shadow-md fade-in hover:shadow-lg transition" style="animation-delay: 0.1s">
            <div class="flex items-center mb-5">
                <div class="flex items-center justify-center h-12 w-12 rounded-xl bg-amber-400 text-white mr-3">
                    <i class="fas fa-receipt"></i>
                </div>
                <h2 class="font-semibold text-lg text-gray-800">Search by Order No</h2>
            </div>
<form class="space-y-4" onsubmit="event.preventDefault(); goToOrder();">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Order Number</label>
                    <div class="relative">
                        <input id="orderNoInput" type="text" placeholder=""
    class="w-full text-black placeholder:text-black rounded-xl border-2 border-blue-400 px-4 py-3 pl-11 focus:outline-none focus:ring-2 focus:ring-blue-500">

                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fas fa-search text-gray-400"></i>
                        </div>
                    </div>
                </div>
                <button type="submit"
                    class="w-full inline-flex items-center justify-center rounded-xl px-4 py-3 font-medium bg-amber-400 text-white hover:bg-amber-500 active:scale-[.98] transition">
                    Track Order
                    <i class="fas fa-arrow-right ml-2"></i>
                </button>
            </form>

        </div>

        {{-- Search by Phone --}}
        <div class="rounded-2xl bg-gradient-to-br from-blue-100 to-blue-50 p-6 shadow-md fade-in hover:shadow-lg transition" style="animation-delay: 0.2s">
            <div class="flex items-center mb-5">
                <div class="flex items-center justify-center h-12 w-12 rounded-xl bg-blue-500 text-white mr-3">
                    <i class="fas fa-mobile-alt"></i>
                </div>
                <h2 class="font-semibold text-lg text-gray-800">Search by Phone</h2>
            </div>
            <form class="space-y-4" method="GET" action="{{ route('phone.search') }}">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Phone Number</label>
                    <div class="relative">
                        <input name="phone" type="text" placeholder=""
    class="w-full text-black placeholder:text-black rounded-xl border-2 border-blue-400 px-4 py-3 pl-11 focus:outline-none focus:ring-2 focus:ring-blue-500"
    required>

                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fas fa-phone text-gray-400"></i>
                        </div>
                    </div>
                </div>
                <button type="submit"
                    class="w-full inline-flex items-center justify-center rounded-xl px-4 py-3 font-medium bg-blue-500 text-white hover:bg-blue-600 active:scale-[.98] transition">
                    Find My Orders
                    <i class="fas fa-arrow-right ml-2"></i>
                </button>
            </form>
        </div>
    </div>
@endsection

@push('scripts')
<script>
    function goToOrder() {
        const v = document.getElementById('orderNoInput').value.trim();
        if (!v) {
            const alertEl = document.createElement('div');
            alertEl.className = 'fixed top-4 right-4 bg-red-100 border border-red-200 text-red-700 px-4 py-3 rounded-xl shadow-md flex items-start space-x-2 max-w-sm z-50';
            alertEl.innerHTML = `
                <div class="flex-shrink-0 mt-0.5">
                    <i class="fas fa-exclamation-circle"></i>
                </div>
                <div>
                    <p class="text-sm font-medium">Please enter Order No</p>
                </div>
            `;
            document.body.appendChild(alertEl);
            setTimeout(() => alertEl.remove(), 3000);
            return;
        }
        window.location.href = `/order/${encodeURIComponent(v)}`;
    }
</script>
@endpush

