@extends('layouts.app')

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

@section('styles')
<style>
    .track-order-container {
        max-width: 500px;
        margin: 4rem auto;
        text-align: center;
    }

    h1 {
        color: var(--accent-dark);
        margin-bottom: 1rem;
    }

    .subtitle {
        color: #666;
        font-size: 1rem;
        margin-bottom: 2rem;
        line-height: 1.6;
    }

    .track-form {
        margin-bottom: 1.5rem;
    }

    .form-group {
        margin-bottom: 1.5rem;
        text-align: left;
    }

    .form-group label {
        display: block;
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: var(--primary-color);
        font-size: 0.95rem;
    }

    .form-group input {
        width: 100%;
        padding: 0.75rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 1rem;
        font-family: inherit;
        transition: all 0.3s ease;
    }

    .form-group input:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(45, 80, 71, 0.1);
    }

    .form-group input::placeholder {
        color: #999;
    }

    .error-message {
        color: #d32f2f;
        font-size: 0.9rem;
        margin-top: 0.5rem;
    }

    .info-box {
        font-size: 0.9rem;
        color: var(--text-secondary);
    }

    .back-link {
        display: block;
        text-align: center;
        margin-top: 1.5rem;
        color: var(--primary-color);
        text-decoration: none;
        font-weight: 500;
    }

    .back-link:hover {
        text-decoration: underline;
    }

    .alert {
        padding: 1rem;
        border-radius: 20px;
        margin-bottom: 1.5rem;
        border: 1px solid;
    }

    .alert-error {
        background-color: #ffebee;
        border-color: #f8d7da;
        color: #c62828;
    }
</style>
@endsection

@section('content')
<main class="container">
    <div class="track-order-container">
        <h1>Track Your Order</h1>
        <p class="subtitle">
            Enter your order number and email address to view the status and details of your order.
        </p>

        @if ($errors->any())
            <div class="alert alert-error">
                @foreach ($errors->all() as $error)
                    <div>{{ $error }}</div>
                @endforeach
            </div>
        @endif

        <form action="{{ route('track-order-search') }}" method="POST">
            @csrf
            <div class="card">
                <div class="form-group">
                    <label for="order_number">Order Number</label>
                    <input 
                        type="text" 
                        id="order_number" 
                        name="order_number" 
                        placeholder="e.g., ORD-20251230-5F3A2C1B"
                        value="{{ old('order_number') }}"
                        required
                    >
                    @error('order_number')
                        <div class="error-message">{{ $message }}</div>
                    @enderror
                </div>

                <div class="form-group">
                    <label for="email">Email Address</label>
                    <input 
                        type="email" 
                        id="email" 
                        name="email" 
                        placeholder="your@email.com"
                        value="{{ old('email') }}"
                        required
                    >
                    @error('email')
                        <div class="error-message">{{ $message }}</div>
                    @enderror
                </div>

                <input type="submit" class="btn" value="Find Your Order" style="width: 100%; cursor: pointer;">

                <div class="info-box card--pink" style="margin-top: 1.5rem; margin-bottom: 0;">
                    💡 Your order number can be found in the confirmation email sent to you after purchase. The email address must match the one used when placing the order.
                </div>
            </div>
        </form>

        <a href="{{ route('home') }}" class="back-link">← Back to Home</a>
    </div>
</main>
@endsection

