import { Aurora } from '@/site/components/art/aurora';
import { Reveal } from '@/site/components/motion/reveal';
import { AppointmentWizard } from '@/site/components/sections/appointment-wizard';
import { SectionHeading } from '@/site/components/ui/heading';
import { Clock, MapPin, Phone } from '@/site/components/ui/icons';
import { WhatsAppButton } from '@/site/components/ui/whatsapp-button';
import { useShared } from '@/site/hooks/use-shared';
import { useT } from '@/site/i18n';

type AppointmentSectionProps = {
    action: string;
    interestAction: string;
    privacyUrl: string;
    turnstile: string | null;
};

/**
 * Closing section of the home page (#randevu): the step-by-step
 * appointment request — contact details first — beside the clinic's
 * direct contact details.
 */
export function AppointmentSection({
    action,
    interestAction,
    privacyUrl,
    turnstile,
}: AppointmentSectionProps) {
    const { site } = useShared();
    const t = useT();
    const { contact } = site;
    const copy = t.home.appointment;

    return (
        <section
            id="randevu"
            className="stage-dark section-y relative isolate scroll-mt-(--header-h) overflow-clip"
        >
            <Aurora intensity={0.6} />

            {/* On phones: heading, form, contact details. From lg: the form beside both. */}
            <div className="shell relative grid gap-x-16 gap-y-10 lg:grid-cols-12 lg:grid-rows-[auto_1fr] lg:gap-y-12">
                <SectionHeading
                    eyebrow={copy.eyebrow}
                    title={copy.title}
                    lead={copy.lead}
                    className="lg:col-span-5"
                />

                <Reveal
                    className="lg:col-span-7 lg:col-start-6 lg:row-span-2 lg:row-start-1"
                    delay={80}
                >
                    <AppointmentWizard
                        action={action}
                        interestAction={interestAction}
                        privacyUrl={privacyUrl}
                        turnstile={turnstile}
                    />
                </Reveal>

                <div className="lg:col-span-5 lg:self-start">
                    {contact.phoneHref ||
                    site.whatsapp ||
                    contact.hours ||
                    contact.address ? (
                        <Reveal delay={160}>
                            <p className="text-eyebrow text-soft font-semibold uppercase">
                                {copy.orReach}
                            </p>
                            <div className="mt-5 flex flex-wrap items-center gap-3">
                                {contact.phone && contact.phoneHref ? (
                                    <a
                                        href={contact.phoneHref}
                                        className="group border-line-strong hover:border-accent-fg inline-flex h-11 items-center gap-3 rounded-full border px-6 text-sm font-medium transition-colors duration-300"
                                    >
                                        <Phone className="text-accent-fg size-5" />
                                        {contact.phone}
                                    </a>
                                ) : null}
                                {/* Opens the short form: WhatsApp asks for a name and a phone first. */}
                                <WhatsAppButton />
                            </div>
                            <dl className="text-soft mt-6 flex flex-col gap-3 text-[0.9375rem]">
                                {contact.hours ? (
                                    <div className="flex gap-3">
                                        <dt className="text-accent-fg">
                                            <Clock className="size-5" />
                                            <span className="sr-only">
                                                {t.contact.info.hours}
                                            </span>
                                        </dt>
                                        <dd>{contact.hours}</dd>
                                    </div>
                                ) : null}
                                {contact.address ? (
                                    <div className="flex gap-3">
                                        <dt className="text-accent-fg">
                                            <MapPin className="size-5" />
                                            <span className="sr-only">
                                                {t.contact.info.address}
                                            </span>
                                        </dt>
                                        <dd>{contact.address}</dd>
                                    </div>
                                ) : null}
                            </dl>
                        </Reveal>
                    ) : null}
                </div>
            </div>
        </section>
    );
}
