export const dynamic = 'force-dynamic'
import { redirect } from 'next/navigation'
import { cookies } from 'next/headers'
import { verifySessionToken } from '@/lib/admin-auth'
import { AdminNav } from '@/components/admin/AdminNav'
import PasswortAendern from '@/components/admin/PasswortAendern'
import type { Metadata } from 'next'

export const metadata: Metadata = { title: 'Passwort – Admin' }

export default async function PasswortPage() {
  const cookieStore = await cookies()
  const token = cookieStore.get('admin_session')?.value
  const session = token ? await verifySessionToken(token) : null
  if (!session) redirect('/admin/login')

  return (
    <div className="min-h-screen bg-[#111925]">
      <AdminNav />
      <div className="max-w-2xl mx-auto px-4 py-8">
        <h1 className="text-2xl font-bold tracking-tight mb-2" style={{ color: 'var(--text-primary)' }}>
          Passwort ändern
        </h1>
        <p style={{ fontSize: '13px', color: 'var(--text-muted)', marginBottom: '28px' }}>
          Angemeldet als <strong style={{ color: 'var(--text-primary)' }}>{session.email}</strong>
        </p>
        <PasswortAendern />
      </div>
    </div>
  )
}
