import React from 'react'
import ReactDOM from 'react-dom/client'
import { App } from './App'
import { PreviewOnlyApp } from './PreviewOnlyApp'
import './styles/index.css'

// Find the root element
const rootElement = document.getElementById('boostbot-admin-root')
const previewOnlyRoot = document.getElementById('boostbot-preview-only-root')

if (rootElement) {
  ReactDOM.createRoot(rootElement).render(
    <React.StrictMode>
      <App />
    </React.StrictMode>
  )
} else if (previewOnlyRoot) {
  // Preview-only mode for visual audit
  const widget = previewOnlyRoot.dataset.widget || 'leadform'
  ReactDOM.createRoot(previewOnlyRoot).render(
    <React.StrictMode>
      <PreviewOnlyApp widget={widget} />
    </React.StrictMode>
  )
} else {
  console.error('BoostBot Admin: Root element not found!')
}
