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

console.log("METABETRICS KERNEL: System-Initialisierung...");

const mount = () => {
  const container = document.getElementById('root');
  if (!container) return;

  try {
    const root = ReactDOM.createRoot(container);
    root.render(
      <React.StrictMode>
        <App />
      </React.StrictMode>
    );

    // Smooth Transition
    setTimeout(() => {
      const loader = document.getElementById('boot-loader');
      if (loader) {
        loader.style.transition = 'opacity 0.8s ease, transform 0.8s ease';
        loader.style.opacity = '0';
        loader.style.transform = 'scale(1.05)';
        setTimeout(() => {
          loader.style.display = 'none';
        }, 800);
      }
      console.log("METABETRICS KERNEL: System bereit.");
    }, 1000);
  } catch (err) {
    console.error("METABETRICS KERNEL CRASH:", err);
    const status = document.getElementById('debug-status');
    if (status) status.innerHTML = "SYSTEM CRASH: " + err.message;
  }
};

mount();