import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { VENDEDOR } from "@/lib/vendedor";

const geistSans = Geist({
  variable: "--font-geist-sans",
  subsets: ["latin"],
});

const geistMono = Geist_Mono({
  variable: "--font-geist-mono",
  subsets: ["latin"],
});

export const metadata: Metadata = {
  // Endereço público do site (imagens de compartilhamento etc.). Trocar de domínio = mudar SITE_URL.
  metadataBase: new URL(process.env.SITE_URL ?? "https://www.felipetosin.com.br"),
  title: "Felipe Tosin | Artista Visual",
  description: "Loja oficial de Felipe Tosin: obras originais em pastel oleoso sobre papel e edições limitadas numeradas e assinadas, com certificado, impressas em fine art sobre papel Hahnemühle.",
  alternates: { canonical: "./" },
  ...(process.env.SITE_PRIVADO === "1" ? { robots: { index: false, follow: false } } : {}),
  openGraph: {
    type: "website",
    locale: "pt_BR",
    siteName: "Felipe Tosin",
    title: "Felipe Tosin | Artista Visual",
    description: "Obras originais em pastel oleoso e edições limitadas numeradas e assinadas. Envio para todo o Brasil.",
    images: [{ url: "/og.jpg", width: 1200, height: 630, alt: "Felipe Tosin, artista visual" }],
  },
  twitter: { card: "summary_large_image" },
};

const SITE = (process.env.SITE_URL ?? "https://www.felipetosin.com.br").replace(/\/+$/, "");
// Dados do artista e do site para o Google (nome, cidade e redes). Só cidade/UF: o endereço completo não é publicado aqui.
const dadosEstruturados = [
  {
    "@context": "https://schema.org",
    "@type": "Person",
    name: VENDEDOR.nome,
    jobTitle: "Artista visual",
    url: SITE,
    image: `${SITE}/og.jpg`,
    address: { "@type": "PostalAddress", addressLocality: "Curitiba", addressRegion: "PR", addressCountry: "BR" },
    ...(VENDEDOR.instagram ? { sameAs: [`https://www.instagram.com/${VENDEDOR.instagram.replace("@", "")}`] } : {}),
  },
  { "@context": "https://schema.org", "@type": "WebSite", name: "Felipe Tosin", url: SITE, inLanguage: "pt-BR" },
];

export default function RootLayout({ children }: LayoutProps<"/">) {
  return (
    <html
      lang="pt-BR"
      className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
    >
      <body className="min-h-full flex flex-col bg-white text-zinc-900">
        <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(dadosEstruturados) }} />
        <header className="border-b border-zinc-200">
          <div className="mx-auto flex max-w-6xl items-center justify-between px-6 py-5">
            <a href="/" className="text-lg font-semibold tracking-tight">
              FELIPE TOSIN
            </a>
            <nav className="flex items-center gap-6 text-sm text-zinc-600">
              <a href="/" className="hover:text-zinc-900">Loja</a>
              <a href="/sobre" className="hover:text-zinc-900">Sobre</a>
              <a href="/exposicoes" className="hover:text-zinc-900">Exposições</a>
              <a href="/contato" className="hover:text-zinc-900">Contato</a>
            </nav>
          </div>
        </header>
        <div className="flex flex-1 flex-col">{children}</div>
        <footer className="border-t border-zinc-200 py-8 text-xs text-zinc-500">
          <div className="mx-auto max-w-6xl space-y-2 px-6 text-center">
            <p>
              © {new Date().getFullYear()} Felipe Tosin. Obras originais (peças únicas) e edições limitadas de 15 cópias por formato, numeradas e assinadas, com certificado de autenticidade.
            </p>
            <p className="space-x-4">
              <a href="/perguntas-frequentes" className="hover:text-zinc-900">Perguntas frequentes</a>
              <a href="/troca-e-devolucao" className="hover:text-zinc-900">Troca e devolução</a>
              <a href="/privacidade" className="hover:text-zinc-900">Privacidade</a>
              <a href="/contato" className="hover:text-zinc-900">Contato</a>
            </p>
            {VENDEDOR.documento && (
              <p>
                {VENDEDOR.nome} · {VENDEDOR.documento}
                {VENDEDOR.endereco ? ` · ${VENDEDOR.endereco}` : ""}
              </p>
            )}
          </div>
        </footer>
      </body>
    </html>
  );
}
