import React from 'react';
import { Head } from '@inertiajs/react';

interface SEOProps {
    title?: string;
    description?: string;
    keywords?: string;
    image?: string;
    canonical?: string;
    type?: string;
    robots?: string;
    author?: string;
    schema?: object;
}

export const SEOHead: React.FC<SEOProps> = ({
    title = 'Tech in Soul | Modern Cloud, AI & Enterprise Software Engineering Solutions',
    description = 'Tech in Soul is an elite IT solutions firm delivering modern web applications, scalable cloud infrastructure, AI integrations, mobile apps, and custom software worldwide.',
    keywords = 'Tech in Soul, software engineering, web development, cloud architecture, AI automation, full-stack, enterprise solutions, Bangladesh IT company',
    image = '/assets/og-cover.png',
    canonical,
    type = 'website',
    robots = 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1',
    author = 'Tech in Soul Engineering Team',
    schema,
}) => {
    const fullTitle = title.includes('Tech in Soul') ? title : `${title} | Tech in Soul`;

    return (
        <Head>
            <title>{fullTitle}</title>
            <meta name="description" content={description} />
            <meta name="keywords" content={keywords} />
            <meta name="author" content={author} />
            <meta name="robots" content={robots} />
            <meta name="theme-color" content="#060B18" />

            {/* OpenGraph / Facebook / LinkedIn / WhatsApp */}
            <meta property="og:site_name" content="Tech in Soul" />
            <meta property="og:type" content={type} />
            <meta property="og:title" content={fullTitle} />
            <meta property="og:description" content={description} />
            <meta property="og:image" content={image} />
            {canonical && <meta property="og:url" content={canonical} />}
            <meta property="og:locale" content="en_US" />

            {/* Twitter */}
            <meta name="twitter:card" content="summary_large_image" />
            <meta name="twitter:title" content={fullTitle} />
            <meta name="twitter:description" content={description} />
            <meta name="twitter:image" content={image} />

            {/* Canonical Link */}
            {canonical && <link rel="canonical" href={canonical} />}

            {/* Favicons */}
            <link rel="icon" type="image/x-icon" href="/favicon.ico" />
            <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
            <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
            <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
            <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
            <link rel="apple-touch-icon-precomposed" sizes="180x180" href="/apple-touch-icon-precomposed.png" />


            {/* Structured Schema LD+JSON */}
            {schema && (
                <script type="application/ld+json">
                    {JSON.stringify(schema)}
                </script>
            )}
        </Head>
    );
};
