'use client'

import { lazy, Suspense } from 'react'

import { AdminGuard } from '@/components/admin/admin-guard'

// Ленивая загрузка тяжелого админского дашборда
const AdminDashboard = lazy(() =>
  import('@/components/admin/admin-dashboard').then((mod) => ({
    default: mod.AdminDashboard,
  })),
)

// Компонент загрузки
function LoadingFallback() {
  return (
    <div className="flex items-center justify-center min-h-screen">
      <div className="text-center space-y-4">
        <div className="w-8 h-8 border-4 border-purple-600 border-t-transparent rounded-full animate-spin mx-auto"></div>
        <p className="text-white/60">Загрузка админ панели...</p>
      </div>
    </div>
  )
}

export default function AdminDashboardPage() {
  return (
    <AdminGuard>
      <Suspense fallback={<LoadingFallback />}>
        <AdminDashboard />
      </Suspense>
    </AdminGuard>
  )
}
