import Head from 'next/head'
import { DocsSidebar } from '@/components/DocsSidebar'
import { DocsContent } from '@/components/DocsContent'
import { PageHeader } from '@/components/PageHeader'
import { Footer } from '@/components/Footer'
import { useDocs } from '@/hooks/useDocs'
import { t } from '@/lib/i18n'

type DocSection = 'user-guide' | 'faq' | 'publishing' | 'payment'

interface DocLink {
  id: DocSection
  title: string
  file: string
}

const docs: DocLink[] = [
  {
    id: 'user-guide',
    title: 'Guide d\'utilisation',
    file: 'user-guide.md',
  },
  {
    id: 'faq',
    title: 'FAQ',
    file: 'faq.md',
  },
  {
    id: 'publishing',
    title: 'Guide de publication',
    file: 'publishing-guide.md',
  },
  {
    id: 'payment',
    title: 'Guide de paiement',
    file: 'payment-guide.md',
  },
]

export default function DocsPage() {
  const { selectedDoc, docContent, loading, loadDoc } = useDocs(docs)

  return (
    <>
      <Head>
        <title>{t('nav.documentation')} - zapwall.fr</title>
        <meta name="description" content="Documentation complète pour zapwall.fr" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
      </Head>
      <main className="min-h-screen bg-cyber-darker">
        <PageHeader />
        <div className="max-w-7xl mx-auto px-4 py-8">
          <div className="flex flex-col lg:flex-row gap-8">
            <DocsSidebar
              docs={docs}
              selectedDoc={selectedDoc}
              onSelectDoc={(slug) => {
                void loadDoc(slug)
              }}
            />
            <div className="flex-1">
              <DocsContent content={docContent} loading={loading} />
            </div>
          </div>
        </div>
        <Footer />
      </main>
    </>
  )
}
