import React from 'react';
import { PublicHeader } from '@/Components/PublicHeader';
import { PublicFooter } from '@/Components/PublicFooter';
import { SEOHead } from '@/Components/SEOHead';

interface DynamicPageProps {
    page: any;
}

export default function DynamicPage({ page }: DynamicPageProps) {
    return (
        <div className="min-h-screen bg-[#060B18] text-slate-100 flex flex-col font-sans">
            <SEOHead
                title={`${page.meta_title || page.title} | Tech in Soul`}
                description={page.meta_description || page.excerpt}
            />

            <PublicHeader />

            <main className="flex-grow pt-32 pb-20">
                <div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-8">
                    <h1 className="text-4xl font-extrabold text-white tracking-tight">
                        {page.title}
                    </h1>

                    <div className="glass-card rounded-3xl p-8 lg:p-12 space-y-6 text-slate-300 leading-relaxed text-base">
                        {page.content}
                    </div>

                    {/* Dynamic Sections Renderer */}
                    {page.sections && page.sections.length > 0 && (
                        <div className="space-y-8 pt-8">
                            {page.sections.map((section: any) => (
                                <div key={section.id} className="glass-card rounded-2xl p-6 border border-slate-800">
                                    {section.title && <h3 className="text-xl font-bold text-white mb-2">{section.title}</h3>}
                                    <pre className="text-xs text-slate-400 overflow-x-auto">{JSON.stringify(section.content, null, 2)}</pre>
                                </div>
                            ))}
                        </div>
                    )}
                </div>
            </main>

            <PublicFooter />
        </div>
    );
}
