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

const rootElement = document.getElementById('root');

try {
  if (!rootElement) {
    throw new Error("Fatal Error: The root element with id 'root' was not found in the DOM.");
  }
  
  ReactDOM.createRoot(rootElement).render(
    <App />
  );
} catch (error) {
  console.error("Fatal error during React initialization:", error);
  if (rootElement) {
    rootElement.innerHTML = `<div style="font-family: sans-serif; padding: 2rem; color: #b91c1c; background-color: #fee2e2; height: 100vh; display: flex; align-items: center; justify-content: center;"><h1>Erro de inicialização</h1><p>Verifique o console.</p></div>`;
  }
}
