import { Aurora } from '@/site/components/art/aurora';
import { Reveal } from '@/site/components/motion/reveal';
import { CrmForm } from '@/site/components/sections/crm-form';
import { WhatsAppForm } from '@/site/components/sections/whatsapp-form';
import { SectionHeading } from '@/site/components/ui/heading';
import { WhatsApp } from '@/site/components/ui/icons';
import { useShared } from '@/site/hooks/use-shared';
import { useT } from '@/site/i18n';
import { cx } from '@/site/lib/cx';
import type { Stats } from '@/site/types';

/**
 * WhatsApp band of the home page (#whatsapp): the visitor leaves a name
 * and a phone number, the request is stored and its answer names the
 * number to chat with — then WhatsApp opens. There is no link to a
 * WhatsApp number here or anywhere else (docs/DECISIONS.md K39).
 *
 * With the CRM forms on the form is the CRM's and the number is that of
 * the person who will take the chat; otherwise the form is the site's own
 * (Talepler) and the number the clinic's. While WhatsApp is not offered
 * there is nothing to show.
 *
 * The ring beside the form carries real figures only (areas and
 * treatments published on the site).
 */
export function WhatsAppBand({ stats }: { stats: Stats }) {
    const { site } = useShared();
    const t = useT();
    const copy = t.home.whatsapp;

    if (!site.whatsapp) {
        return null;
    }

    return (
        <section
            id="whatsapp"
            className="stage-dark section-y-sm relative isolate scroll-mt-(--header-h) overflow-clip"
        >
            <Aurora intensity={0.55} />
            {/* WhatsApp's green, as a light from the corner. */}
            <div
                aria-hidden="true"
                className="pointer-events-none absolute -end-40 -bottom-56 -z-10 size-[44rem] bg-[radial-gradient(closest-side,var(--color-whatsapp),transparent)] opacity-20"
            />

            <div className="shell relative grid items-center gap-12 lg:grid-cols-12">
                <div className="lg:col-span-9">
                    <SectionHeading
                        eyebrow={
                            <>
                                <WhatsApp className="text-whatsapp size-[1.6em]" />
                                {copy.eyebrow}
                            </>
                        }
                        title={copy.title}
                        lead={copy.lead}
                    />

                    {/* The CRM's frame keeps room below the fields for the
                        country list; from tablet width it lends that room to
                        the section's own padding. */}
                    <Reveal
                        delay={160}
                        className={cx('mt-9', site.crm && 'md:-mb-16')}
                    >
                        {site.crm ? (
                            <CrmForm config={site.crm} kind="whatsapp" />
                        ) : (
                            <WhatsAppForm config={site.whatsapp} />
                        )}
                    </Reveal>
                </div>

                <Reveal
                    delay={240}
                    scale={0.92}
                    className="hidden justify-self-center lg:col-span-3 lg:block"
                >
                    <p className="border-line-strong bg-stage-2/60 grid size-56 place-content-center gap-1 rounded-full border text-center">
                        <span className="text-soft text-sm">
                            {copy.across(stats.categories)}
                        </span>
                        <span className="font-display text-6xl leading-none font-[280] tabular-nums">
                            {stats.treatments}
                        </span>
                        <span className="font-medium">
                            {t.home.stats.treatments}
                        </span>
                    </p>
                </Reveal>
            </div>
        </section>
    );
}
