/* --- src/app.jsx --- */
// App entry — wire screens
const { useState: useS } = React;

function App(){
  const [current, setCurrent] = useS('home');
  React.useEffect(()=>{ window.__goReport = ()=> setCurrent('insight'); return ()=>{ delete window.__goReport; }; },[]);
  const screens = {
    home:      <HomeScreen go={setCurrent}/>,
    dashboard: <DashboardScreen go={setCurrent}/>,
    upper:     <UpperLawScreen go={setCurrent}/>,
    compare:   <CompareScreen go={setCurrent}/>,
    lower:     <LowerScreen go={setCurrent}/>,
    forms:     <FormsScreen go={setCurrent}/>,
    report:    <ReportScreen go={setCurrent}/>,
    analysis:  <AnalysisScreen go={setCurrent}/>,
    insight:   <InsightScreen go={setCurrent}/>,
    agencies:  <AgenciesScreen go={setCurrent}/>,
  };
  const labels = {
    home:'01 홈', dashboard:'02 탐지 대시보드', upper:'03 상위법 개정 감지',
    compare:'04 신구조문 비교', lower:'05 하위규정·자치법규 대조',
    forms:'06 민원서식·안내문', report:'07 국민 제보',
    analysis:'08 AI 분석 결과', insight:'09 정합성 리포트', agencies:'10 기관별 정비 현황'
  };
  return (
    <div style={{minHeight:'100vh', background:'var(--bg)'}}>
      <TopBar current={current} setCurrent={setCurrent}/>
      <div style={{display:'flex'}}>
        <Sidebar current={current} setCurrent={setCurrent}/>
        <main data-screen-label={labels[current]} style={{flex:1, minWidth:0}}>
          {screens[current]}
          <footer style={{
            background:'linear-gradient(180deg,#08162E 0%,#071226 100%)', color:'rgba(255,255,255,0.78)', padding:'34px 36px 22px',
            marginTop:32, borderTop:'1px solid rgba(255,255,255,0.10)', boxShadow:'0 -18px 40px rgba(15,23,42,0.10)'
          }}>
            <div style={{display:'grid', gridTemplateColumns:'1.25fr 0.95fr 1.05fr 1.05fr 1.2fr', gap:30, marginBottom:24, alignItems:'start'}}>
              <div>
                <div style={{width:42, height:42, borderRadius:13, background:'linear-gradient(135deg,#0E4A8A,#5EE6B5)', color:'#fff', display:'grid', placeItems:'center', fontSize:12, fontWeight:900, marginBottom:12}}>법령</div>
                <div style={{fontSize:15, fontWeight:800, color:'#fff', marginBottom:7}}>Sync<span style={{color:'#5EE6B5'}}>·</span>Law</div>
                <div style={{fontSize:11.7, lineHeight:1.75, opacity:.72, maxWidth:300}}>법제처 법령데이터와 AI를 활용해 상위법 개정, 하위규정, 자치법규, 민원서식 정비 필요성을 한 화면에서 연결해 보는 법령 정합성 점검 플랫폼입니다.</div>
                <div style={{display:'flex', gap:6, flexWrap:'wrap', marginTop:14}}>
                  <span style={{display:'inline-flex', padding:'5px 9px', borderRadius:999, background:'rgba(94,230,181,0.13)', border:'1px solid rgba(94,230,181,0.20)', color:'#B7F7DF', fontSize:10.5, fontWeight:800}}>법제처</span>
                  <span style={{display:'inline-flex', padding:'5px 9px', borderRadius:999, background:'rgba(125,169,230,0.13)', border:'1px solid rgba(125,169,230,0.20)', color:'#CFE1FF', fontSize:10.5, fontWeight:800}}>국가법령정보</span>
                  <span style={{display:'inline-flex', padding:'5px 9px', borderRadius:999, background:'rgba(255,255,255,0.08)', border:'1px solid rgba(255,255,255,0.12)', color:'#fff', fontSize:10.5, fontWeight:800}}>자치법규</span>
                </div>
              </div>
              <div>
                <div style={{fontSize:11, fontWeight:800, letterSpacing:'0.06em', color:'#7DA9E6', marginBottom:10}}>서비스</div>
                <button type='button' onClick={()=>setCurrent('home')} style={{display:'block', background:'transparent', border:0, padding:'4px 0', margin:0, color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, cursor:'pointer', textAlign:'left'}}>홈</button>
                <button type='button' onClick={()=>setCurrent('dashboard')} style={{display:'block', background:'transparent', border:0, padding:'4px 0', margin:0, color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, cursor:'pointer', textAlign:'left'}}>탐지 대시보드</button>
                <button type='button' onClick={()=>setCurrent('compare')} style={{display:'block', background:'transparent', border:0, padding:'4px 0', margin:0, color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, cursor:'pointer', textAlign:'left'}}>신구조문 비교</button>
                <button type='button' onClick={()=>setCurrent('lower')} style={{display:'block', background:'transparent', border:0, padding:'4px 0', margin:0, color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, cursor:'pointer', textAlign:'left'}}>하위규정·자치법규 대조</button>
                <button type='button' onClick={()=>setCurrent('analysis')} style={{display:'block', background:'transparent', border:0, padding:'4px 0', margin:0, color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, cursor:'pointer', textAlign:'left'}}>AI 분석 결과</button>
              </div>
              <div>
                <div style={{fontSize:11, fontWeight:800, letterSpacing:'0.06em', color:'#7DA9E6', marginBottom:10}}>법제처 바로가기</div>
                <a href='https://www.moleg.go.kr/' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>법제처 누리집 ↗</a>
                <a href='https://www.law.go.kr/' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>국가법령정보센터 ↗</a>
                <a href='https://opinion.lawmaking.go.kr/' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>국민참여입법센터 ↗</a>
                <a href='https://open.law.go.kr/LSO/main.do' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>국가법령정보 공동활용 ↗</a>
              </div>
              <div>
                <div style={{fontSize:11, fontWeight:800, letterSpacing:'0.06em', color:'#7DA9E6', marginBottom:10}}>기준·해석</div>
                <a href='https://www.moleg.go.kr/menu.es?mid=a10105030000' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>법령입안심사기준 ↗</a>
                <a href='https://www.moleg.go.kr/menu.es?mid=a10103030000' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>행정규칙 입안·심사기준 ↗</a>
                <a href='https://www.moleg.go.kr/menu.es?mid=a10106020000' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>법령해석 사례 ↗</a>
                <a href='https://www.elis.go.kr/' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>자치법규정보시스템 ↗</a>
              </div>
              <div>
                <div style={{fontSize:11, fontWeight:800, letterSpacing:'0.06em', color:'#7DA9E6', marginBottom:10}}>관련 데이터 출처</div>
                <a href='https://open.law.go.kr/LSO/openApi/guideList.do' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>국가법령정보 Open API 가이드 ↗</a>
                <a href='https://www.data.go.kr/data/15000115/openapi.do' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>국가법령정보 공유서비스 API ↗</a>
                <a href='https://www.data.go.kr/data/15157095/openapi.do' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>지능형 법령검색 API ↗</a>
                <a href='https://www.data.go.kr/data/15059136/openapi.do' target='_blank' rel='noopener noreferrer' style={{display:'block', color:'rgba(255,255,255,0.76)', fontSize:11.7, fontWeight:700, padding:'4px 0'}}>법령해석례 목록 API ↗</a>
              </div>
            </div>
            <div style={{borderTop:'1px solid rgba(255,255,255,0.12)', paddingTop:15, marginTop:18, display:'flex', justifyContent:'space-between', gap:16, flexWrap:'wrap', fontSize:10.7, opacity:.65}}>
              <span>© 2026 Sync·Law · 「제2회 법령데이터 활용 아이디어 공모전」 출품작 시연 화면 · 표시된 점수·기관·수치는 심사용 예시 데이터입니다. 모든 분석 결과는 담당기관 검토용 보조자료로, 최종 법적 판단은 법제처·소관부처·지자체에서 수행합니다.</span>
              <span className='mono'>build law-ai-footer · source-linked prototype</span>
            </div>
          </footer>
        </main>
      </div>
      <ToastHost/>
      <ModalHost/>
      <ReportLoadingHost/>
      <CitizenAnalysisModal/>
      <GlobalClickDelegator/>
    </div>
  );
}
ReactDOM.createRoot(document.getElementById('root')).render(<App/>);

