'use client'

import type { AdvisorTurn } from './useAdvisorStream'
import { StatsBar } from './StatsBar'
import { AnswerPane } from './AnswerPane'
import { SourcesPane } from './SourcesPane'
import { FiguresPane } from './FiguresPane'
import { FootnotesPane } from './FootnotesPane'

/** One question/answer turn rendered as stacked evidence panels. */
export function TurnView({ turn, showQuestion }: { turn: AdvisorTurn; showQuestion?: boolean }) {
  const streaming = turn.status === 'streaming'
  return (
    <div className="space-y-2 border-b border-gray-100 pb-4 last:border-0">
      {showQuestion && (
        <div className="text-xs text-gray-500">
          <span className="font-medium text-gray-400">Frage:</span> {turn.question}
        </div>
      )}
      <StatsBar stats={turn.meta.stats} />
      <AnswerPane answer={turn.answer} streaming={streaming} error={turn.error} />
      <SourcesPane sources={turn.meta.sources} />
      <FiguresPane figures={turn.meta.figures} />
      <FootnotesPane footnotes={turn.meta.footnotes} />
    </div>
  )
}
