import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'

// Error Boundary / Global Error Handler to catch white-screen issues
window.addEventListener('error', (event) => {
  document.body.innerHTML = `<div style="color:red; padding:20px; font-size:20px; background:black; height:100vh;">
    <h1>React Crash Error:</h1>
    <pre>${event.error ? event.error.stack : event.message}</pre>
  </div>`;
});

window.addEventListener('unhandledrejection', (event) => {
  document.body.innerHTML = `<div style="color:orange; padding:20px; font-size:20px; background:black; height:100vh;">
    <h1>Unhandled Promise Rejection:</h1>
    <pre>${event.reason}</pre>
  </div>`;
});

ReactDOM.createRoot(document.getElementById('root')).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
)
