
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { Toaster } from 'sonner';
import App from './App';
import { AuthProvider } from './hooks/useAuth';
import { ThemeProvider } from './contexts/ThemeContext';
import './index.css';

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

        {/* Global Toast System - placed at root level for proper z-index and positioning */}
        <Toaster
          position="top-right"
          richColors
          closeButton
          theme="system"
          toastOptions={{
            duration: 3500,
            className: 'bg-card text-card-foreground border border-border shadow-lg',
            success: {
              className: 'border-l-emerald-500',
            },
            error: {
              className: 'border-l-red-500',
            },
            warning: {
              className: 'border-l-amber-500',
            },
            info: {
              className: 'border-l-blue-500',
            },
          }}
        />
      </BrowserRouter>
    </ThemeProvider>
  </React.StrictMode>
);
