<script setup>
    import Checkbox from '@/Components/Checkbox.vue';
    import GuestLayout from '@/Layouts/GuestLayout.vue';
    import InputError from '@/Components/InputError.vue';
    import InputLabel from '@/Components/InputLabel.vue';
    import PrimaryButton from '@/Components/PrimaryButton.vue';
    import TextInput from '@/Components/TextInput.vue';
    import { Head, Link, useForm } from '@inertiajs/vue3';
    
    defineProps({
        canResetPassword: {
            type: Boolean,
        },
        status: {
            type: String,
        },
    });
    
    const form = useForm({
        email: '',
        password: '',
        remember: false,
    });
    
    const submit = () => {
        form.post(route('login'), {
            onFinish: () => form.reset('password'),
        });
    };
    </script>
    
    <template>
        <GuestLayout>
            <Head title="Login - OmniBoard" />
    
            <div class="mb-6 text-center">
                <h2 class="text-2xl font-bold text-ingline-800">Bem-vindo de volta</h2>
                <p class="text-sm text-gray-500 mt-2">Acesse o painel de controle da sua operação</p>
            </div>
    
            <div v-if="status" class="mb-4 text-sm font-medium text-green-600">
                {{ status }}
            </div>
    
            <form @submit.prevent="submit">
                <div>
                    <InputLabel for="email" value="E-mail Corporativo" class="text-gray-700" />
    
                    <TextInput
                        id="email"
                        type="email"
                        class="mt-1 block w-full border-gray-300 focus:border-ingline-500 focus:ring-ingline-500 rounded-md shadow-sm"
                        v-model="form.email"
                        required
                        autofocus
                        autocomplete="username"
                        placeholder="exemplo@empresa.com"
                    />
    
                    <InputError class="mt-2" :message="form.errors.email" />
                </div>
    
                <div class="mt-4">
                    <InputLabel for="password" value="Senha" class="text-gray-700" />
    
                    <TextInput
                        id="password"
                        type="password"
                        class="mt-1 block w-full border-gray-300 focus:border-ingline-500 focus:ring-ingline-500 rounded-md shadow-sm"
                        v-model="form.password"
                        required
                        autocomplete="current-password"
                        placeholder="••••••••"
                    />
    
                    <InputError class="mt-2" :message="form.errors.password" />
                </div>
    
                <div class="flex items-center justify-between mt-4">
                    <label class="flex items-center">
                        <Checkbox name="remember" v-model:checked="form.remember" class="text-ingline-600 focus:ring-ingline-500" />
                        <span class="ms-2 text-sm text-gray-600">Lembrar dispositivo</span>
                    </label>
    
                    <Link
                        v-if="canResetPassword"
                        :href="route('password.request')"
                        class="text-sm text-ingline-500 hover:text-ingline-700 font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ingline-500"
                    >
                        Esqueceu a senha?
                    </Link>
                </div>
    
                <div class="mt-6">
                    <PrimaryButton
                        class="w-full justify-center py-3 bg-ingline-500 hover:bg-ingline-600 focus:bg-ingline-700 active:bg-ingline-700 transition duration-150 ease-in-out"
                        :class="{ 'opacity-75': form.processing }"
                        :disabled="form.processing"
                    >
                        Acessar Plataforma
                    </PrimaryButton>
                </div>
                
                <div class="mt-6 text-center">
                    <p class="text-xs text-gray-400">
                        Protegido por Ingline Systems © 2025
                    </p>
                </div>
            </form>
        </GuestLayout>
    </template>