import { useState, useEffect } from 'react'
import Examples from './components/Examples'
import LeaderboardPage from './components/LeaderboardPage'

function App() {
  const [activeTab, setActiveTab] = useState<
    'leaderboard' | 'imageExamples' | 'audioExamples' | 'videoExamples'
  >('leaderboard')
  const [theme, setTheme] = useState<'dark' | 'light'>('dark')

  useEffect(() => {
    document.documentElement.setAttribute('data-theme', theme)
  }, [theme])

  return (
    <div className="min-h-screen w-11/12 mx-auto">
      <div className="bg-base-100 my-4">
        <div className="flex flex-row justify-between items-center">
          <h2 className="card-title">🥇 Omni Seal Bench Watermarking Leaderboard</h2>
          <div className="flex justify-end items-center gap-2">
            <span className="text-sm">{theme === 'dark' ? '🌙 Dark Mode' : '☀️ Light Mode'}</span>
            <input
              type="checkbox"
              className="toggle"
              checked={theme === 'dark'}
              onChange={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
              aria-label="Toggle dark mode"
            />
          </div>
        </div>
      </div>

      <div className="tabs tabs-border">
        <input
          type="radio"
          name="my_tabs_6"
          className="tab"
          aria-label="Leaderboard Table"
          checked={activeTab === 'leaderboard'}
          onChange={() => setActiveTab('leaderboard')}
        />
        <div className="tab-content bg-base-100  ">
          <LeaderboardPage />
        </div>

        <input
          type="radio"
          name="my_tabs_6"
          className="tab"
          aria-label="Image Examples"
          checked={activeTab === 'imageExamples'}
          onChange={() => setActiveTab('imageExamples')}
        />
        <div className="tab-content bg-base-100  ">
          {activeTab === 'imageExamples' ? <Examples fileType="image" /> : null}
        </div>

        <input
          type="radio"
          name="my_tabs_6"
          className="tab"
          aria-label="Audio Examples"
          checked={activeTab === 'audioExamples'}
          onChange={() => setActiveTab('audioExamples')}
        />
        <div className="tab-content bg-base-100  ">
          {activeTab === 'audioExamples' ? <Examples fileType="audio" /> : null}
        </div>

        <input
          type="radio"
          name="my_tabs_6"
          className="tab"
          aria-label="Video Examples"
          checked={activeTab === 'videoExamples'}
          onChange={() => setActiveTab('videoExamples')}
        />
        <div className="tab-content bg-base-100  ">
          {activeTab === 'videoExamples' ? <Examples fileType="video" /> : null}
        </div>
      </div>
    </div>
  )
}

export default App
