import React from 'react';
import { Outlet, useLocation } from 'react-router-dom';
import Sidebar from './Sidebar';
import Navbar from './Navbar';
import AIChat from './AIChat';

const PAGE_TITLES = {
  '/':             'Dashboard',
  '/projects':     'Proyectos',
  '/projects/new': 'Nuevo proyecto',
  '/gantt':        'Gantt & Ruta Crítica',
  '/wbs':          'EDT / WBS',
  '/risks':        'Registro de Riesgos',
  '/evm':          'Gestión del Valor Ganado',
  '/budget':       'Presupuesto',
  '/team':         'Equipo',
  '/reports':      'Reportes',
  '/messages':     'Mensajes internos',
};

export default function Layout() {
  const { pathname } = useLocation();
  const title = PAGE_TITLES[pathname] || 'AR PM';

  return (
    <div className="flex h-screen overflow-hidden bg-slate-50 dark:bg-surface-900 transition-colors">
      <Sidebar />
      <div className="flex-1 flex flex-col overflow-hidden">
        <Navbar title={title} />
        <main className="flex-1 overflow-y-auto p-6">
          <Outlet />
        </main>
      </div>
      <AIChat />
    </div>
  );
}
