import React from 'react'
import ReactDOM from 'react-dom/client'
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
import App from './App'
import { DaemonList } from './components/DaemonList'
import { DaemonDetail } from './components/DaemonDetail'
import { DocumentLayout } from './components/document'
import './styles/pc98.css'
import './styles/mobile.css'

// Route configuration:
// Primary (Document UI - when feature flag enabled):
// - /directives - Document layout with file tree sidebar and Lexical editor
// - /directives/:id - Open a specific directive in the document editor
//
// Legacy (Contract UI - kept for backward compatibility):
// - /contracts - List all contracts
// - /contracts/:id - View contract details with tabs (including Files tab)
// - /contracts/:contractId/files/:fileId - View a specific file within contract context
//
// Note: When Document UI is enabled via Settings, /directives is the primary interface.
// The /contracts routes remain available as a legacy fallback.

const router = createBrowserRouter([
  {
    path: '/',
    element: <App />,
  },
  {
    path: '/daemons',
    element: <DaemonList />,
  },
  {
    path: '/daemons/:id',
    element: <DaemonDetail />,
  },
  {
    path: '/directives',
    element: <DocumentLayout />,
  },
  {
    path: '/directives/:id',
    element: <DocumentLayout />,
  },
])

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <RouterProvider router={router} />
  </React.StrictMode>
)
