import React from 'react'
import { cookies } from 'next/headers'
import LoginForm from './LoginForm'
import LanguageSelector from '@/components/LanguageSelector'

async function getMessages() {
  const cookieStore = await cookies()
  const lang = cookieStore.get('NEXT_LOCALE')?.value || 'de'
  const messages = await import(`@/messages/${lang}.json`)
  return messages.default
}

export default async function LoginPage() {
  const messages = await getMessages()

  return (
    <div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
      <div className="max-w-md w-full space-y-8">
        <div className="absolute top-4 right-4">
          <LanguageSelector />
        </div>
        
        <div>
          <h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900">
            {messages.login.title}
          </h2>
        </div>
        
        <LoginForm messages={messages} />
      </div>
    </div>
  )
} 