<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Register - {{ config('app.name') }}</title>
    <link rel="icon" href="/favicon.svg" type="image/svg+xml">
    <link rel="icon" href="/favicon.ico" sizes="16x16 32x32 48x48">
    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
    <link rel="manifest" href="/site.webmanifest">
    <meta name="theme-color" content="#2563eb">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="apple-mobile-web-app-title" content="FleetQ">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="preconnect" href="https://fonts.bunny.net">
    <link href="https://fonts.bunny.net/css?family=inter:400,500,600,700" rel="stylesheet" />
    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="flex min-h-screen items-center justify-center bg-gray-50 font-sans antialiased">
    <div class="w-full max-w-md">
        <div class="mb-8 text-center">
            <div class="mb-3 flex justify-center">
                <div class="flex h-12 w-12 items-center justify-center rounded-xl bg-primary-600">
                    <x-logo-icon class="h-7 w-7 text-white" />
                </div>
            </div>
            <h1 class="text-2xl font-bold text-gray-900">{{ config('app.name') }}</h1>
            <p class="mt-2 text-sm text-gray-500">AI Agent Mission Control</p>
        </div>

        <div class="rounded-xl border border-gray-200 bg-white p-8">
            <h2 class="mb-6 text-lg font-semibold text-gray-900">Create account</h2>

            @if ($errors->any())
                <div class="mb-4 rounded-lg bg-red-50 p-4 text-sm text-red-600">
                    @foreach ($errors->all() as $error)
                        <p>{{ $error }}</p>
                    @endforeach
                </div>
            @endif

            <div x-data="{ terms: {{ old('terms') ? 'true' : 'false' }}, termsError: false }">
            <form method="POST" action="{{ route('register') }}">
                @csrf

                <div class="mb-4">
                    <x-form-input label="Name" type="text" id="name" name="name" :value="old('name')" required autofocus autocomplete="name" />
                </div>

                <div class="mb-4">
                    <x-form-input label="Email" type="email" id="email" name="email" :value="old('email')" required autocomplete="username" />
                </div>

                <div class="mb-4">
                    <x-form-input label="Password" type="password" id="password" name="password" required autocomplete="new-password" />
                </div>

                <div class="mb-4">
                    <x-form-input label="Confirm Password" type="password" id="password_confirmation" name="password_confirmation" required autocomplete="new-password" />
                </div>

                <div class="mb-6">
                    <label class="flex items-start gap-3 cursor-pointer">
                        <input type="checkbox" name="terms" id="terms" value="1"
                               x-model="terms"
                               @change="termsError = false"
                               class="mt-0.5 h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500 {{ $errors->has('terms') ? 'border-red-400' : '' }}">
                        <span class="text-sm text-gray-600">
                            I agree to the
                            <a href="{{ route('legal.terms') }}" target="_blank" class="text-primary-600 hover:text-primary-700">Terms of Service</a>
                            and
                            <a href="{{ route('legal.privacy') }}" target="_blank" class="text-primary-600 hover:text-primary-700">Privacy Policy</a>
                        </span>
                    </label>
                    @error('terms')
                        <p class="mt-1.5 text-sm text-red-600">{{ $message }}</p>
                    @enderror
                    <p x-show="termsError" x-cloak class="mt-1.5 text-sm text-red-600">
                        You must agree to the Terms of Service and Privacy Policy.
                    </p>
                </div>

                <button type="submit"
                    class="w-full rounded-lg bg-primary-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2">
                    Create account
                </button>

                <p class="mt-4 text-center text-sm text-gray-500">
                    Already have an account? <a href="{{ route('login') }}" class="text-primary-600 hover:text-primary-700">Sign in</a>
                </p>
            </form>

            <x-social-login-buttons :check-terms="true" /></div>
        </div>
    </div>
</body>
</html>
