'use client'

import Link from 'next/link'
import { type ReactNode } from 'react'
import { LanguageSwitcher } from '@/components/LanguageSwitcher'
import { useLanguage } from '@/components/LanguageProvider'

export function AppFrame({ children }: { children: ReactNode }) {
  const { t } = useLanguage()

  return (
    <>
      <a
        href="#main"
        className="sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-50 focus:rounded-lg focus:bg-shenmo-ivory focus:px-3 focus:py-2 focus:text-shenmo-red"
      >
        {t('nav.skip')}
      </a>
      <div className="shell mx-auto flex min-h-dvh w-full min-w-0 max-w-lg flex-col overflow-x-hidden">
        <header className="flex w-full min-w-0 flex-wrap items-center justify-between gap-2 py-3">
          <Link href="/" className="min-w-0 max-w-full truncate text-base font-semibold text-shenmo-red">
            {t('appName')}
          </Link>
          <LanguageSwitcher />
        </header>
        <main id="main" className="shell-main flex w-full min-w-0 flex-1 flex-col">
          {children}
        </main>
      </div>
    </>
  )
}
