<script setup>
import { Head, Link, useForm } from '@inertiajs/vue3';
import { tokens, FONT } from '@/Components/Diabetix/palette.js';

defineProps({ status: String });

const tok = tokens('mint');
const font = FONT;

const form = useForm({ email: '' });

function submit() {
    form.post(route('password.email'));
}
</script>

<template>
    <Head title="Mot de passe oublié" />

    <div :style="{ minHeight: '100vh', background: '#eeece8', fontFamily: font.body, display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '24px' }">
        <div :style="{ width: '100%', maxWidth: '400px' }">

            <div style="text-align:center;margin-bottom:32px;">
                <div :style="{ width: '64px', height: '64px', borderRadius: '50%', background: tok.light, border: '2px solid ' + tok.primary, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '28px', margin: '0 auto 14px' }">🔑</div>
                <div :style="{ fontFamily: font.title, fontSize: '24px', fontWeight: 700, color: tok.text }">Mot de passe oublié</div>
                <div :style="{ fontSize: '13px', color: tok.muted, marginTop: '6px', lineHeight: 1.5 }">Saisissez votre e-mail — nous vous enverrons un lien pour réinitialiser votre mot de passe.</div>
            </div>

            <div :style="{ background: tok.white, borderRadius: '24px', padding: '28px 24px', boxShadow: '0 4px 24px rgba(42,53,51,0.10)' }">
                <div v-if="status" :style="{ background: tok.light, borderRadius: '12px', padding: '10px 14px', fontSize: '13px', color: tok.dark, marginBottom: '20px' }">
                    {{ status }}
                </div>

                <form @submit.prevent="submit">
                    <div style="margin-bottom:24px;">
                        <label :style="{ fontSize: '11px', color: tok.muted, fontWeight: 600, display: 'block', marginBottom: '6px', textTransform: 'uppercase', letterSpacing: '0.7px' }">Adresse e-mail</label>
                        <input v-model="form.email" type="email" required autofocus autocomplete="username"
                            :style="{ width: '100%', padding: '12px 14px', borderRadius: '14px', border: '1.5px solid ' + tok.border, background: tok.bg, fontSize: '15px', color: tok.text, outline: 'none', boxSizing: 'border-box' }" />
                        <span v-if="form.errors.email" :style="{ fontSize: '11px', color: '#c43', marginTop: '4px', display: 'block' }">{{ form.errors.email }}</span>
                    </div>

                    <button type="submit" :disabled="form.processing"
                        :style="{
                            width: '100%', padding: '15px', background: tok.primary, color: '#fff',
                            borderRadius: '16px', border: 'none', fontSize: '15px', fontWeight: 700,
                            cursor: form.processing ? 'not-allowed' : 'pointer',
                            opacity: form.processing ? 0.6 : 1,
                            boxShadow: '0 6px 18px rgba(123,191,181,0.35)',
                        }">
                        {{ form.processing ? 'Envoi…' : 'Envoyer le lien' }}
                    </button>
                </form>
            </div>

            <div style="text-align:center;margin-top:20px;">
                <Link :href="route('login')" :style="{ fontSize: '13px', color: tok.primary, fontWeight: 600, textDecoration: 'none' }">← Retour à la connexion</Link>
            </div>
        </div>
    </div>
</template>
