'use client';

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';

export default function RootPage() {
    const router = useRouter();

    useEffect(() => {
        // Detect browser language and redirect
        const detectLanguage = () => {
            const browserLang = navigator.language;

            if (browserLang.startsWith('zh-TW') || browserLang.startsWith('zh-HK')) {
                return 'zh-TW';
            } else if (browserLang.startsWith('zh')) {
                return 'zh-CN';
            } else if (browserLang.startsWith('ko')) {
                return 'ko';
            } else if (browserLang.startsWith('ja')) {
                return 'ja';
            } else {
                return 'en';
            }
        };

        const locale = detectLanguage();
        router.replace(`/${locale}`);
    }, [router]);

    return (
        <div
            className="min-h-screen bg-gray-900 flex items-center justify-center"
            data-oid="39r2psi"
        >
            <div className="text-white text-lg" data-oid="s7:o:8p">
                Loading...
            </div>
        </div>
    );
}
