'use client';

import { useState, useEffect } from 'react';
import LoginForm from '@/components/LoginForm';
import ProxyInterface from '@/components/ProxyInterface';
import { useAuthStore } from '@/store/authStore';

export default function Home() {
  const { token, isAuthenticated, checkAuth } = useAuthStore();
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    checkAuth();
    setIsLoading(false);
  }, [checkAuth]);

  if (isLoading) {
    return (
      <div className="min-h-screen flex items-center justify-center">
        <div className="loading-spinner" />
      </div>
    );
  }

  return (
    <main className="min-h-screen">
      {isAuthenticated ? <ProxyInterface /> : <LoginForm />}
    </main>
  );
}
