import type { PropsWithChildren } from 'react';
import AppLogoIcon from '@/components/app-logo-icon';
import {
    Card,
    CardContent,
    CardDescription,
    CardHeader,
    CardTitle,
} from '@/components/ui/card';

type PublicShellProps = {
    title?: string;
    description?: string;
    showLogo?: boolean;
};

export default function PublicShell({
    children,
    title,
    description,
    showLogo = true,
}: PropsWithChildren<PublicShellProps>) {
    return (
        <div className="bg-background flex min-h-screen flex-col items-center justify-center gap-6 p-6 md:p-10">
            <div className="flex w-full max-w-md flex-col gap-6">
                {/* Header with Logo */}
                {showLogo && (
                    <div className="flex items-center gap-2 self-center">
                        <div className="flex h-9 w-9 items-center justify-center">
                            <AppLogoIcon className="text-foreground size-9 fill-current" />
                        </div>
                    </div>
                )}

                {/* Card */}
                <Card className="rounded-xl">
                    {(title || description) && (
                        <CardHeader className="px-10 pt-8 pb-0 text-center">
                            {title && (
                                <CardTitle className="text-xl">
                                    {title}
                                </CardTitle>
                            )}
                            {description && (
                                <CardDescription>{description}</CardDescription>
                            )}
                        </CardHeader>
                    )}

                    <CardContent
                        className={
                            title || description ? 'px-10 py-8' : 'px-10 py-8'
                        }
                    >
                        {children}
                    </CardContent>
                </Card>
            </div>
        </div>
    );
}
