// record-main.jsx — root + router for PulseChart Record.

function RecordApp() {
  const route = useRRoute();
  return (
    <RStoreProvider>
      <RRouteSwitch route={route}/>
    </RStoreProvider>
  );
}

function RRouteSwitch({ route }) {
  switch (route.name) {
    case 'home':       return <RecordHome/>;
    case 'discharge':  return route.sessionId ? <DischargeWorkspace sessionId={route.sessionId}/> : <DischargePicker/>;
    case 'counseling': return route.sessionId
      ? (window.CounselingWorkspace ? <window.CounselingWorkspace sessionId={route.sessionId}/> : <ComingSoon/>)
      : (window.CounselingPicker ? <window.CounselingPicker/> : <ComingSoon/>);
    default:           return <RecordHome/>;
  }
}

function ComingSoon() {
  return (
    <RShell crumb={['Counseling Capture']}>
      <div style={{ maxWidth:600, margin:'80px auto', textAlign:'center', padding:24 }}>
        <div style={{ width:48, height:48, borderRadius:12, background:window.PCT.c.brandSoft, color:window.PCT.c.brand, display:'grid', placeItems:'center', margin:'0 auto 16px' }}><RIcon name="shield" size={24} color={window.PCT.c.brand}/></div>
        <h2 style={{ fontSize:20, fontWeight:600 }}>Counseling Capture</h2>
        <p style={{ color:window.PCT.c.textMuted, fontSize:14, lineHeight:1.6 }}>This module is being built next in the demo. The Discharge Summary module is fully working — try it from the home screen.</p>
        <a href="#/" style={{ textDecoration:'none' }}><RBtn kind="primary" icon="left">Back to home</RBtn></a>
      </div>
    </RShell>
  );
}

const recordRoot = ReactDOM.createRoot(document.getElementById('root'));
recordRoot.render(<RecordApp/>);
