import React from 'react'
import ReactDOM from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'
import { AuthProvider } from './contexts/AuthContext'
import App from './App'
import './index.css'

// Check if running on localhost
if (window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') {
  ReactDOM.createRoot(document.getElementById('root')!).render(
    <div style={{ padding: '2rem', textAlign: 'center', color: '#EF4444' }}>
      <h1>Access Restricted</h1>
      <p>This application can only be accessed from localhost.</p>
      <p>Current hostname: {window.location.hostname}</p>
    </div>
  )
} else {
  ReactDOM.createRoot(document.getElementById('root')!).render(
    <React.StrictMode>
      <BrowserRouter>
        <AuthProvider>
          <App />
        </AuthProvider>
      </BrowserRouter>
    </React.StrictMode>
  )
}
