/* ============ Sales Console — agent UI atoms (Phase 2.1) ============ */
/* Note: hooks (useState etc.) already destructured in components-base.jsx — do not redeclare. */

/* (1) AgentMark — sparkle icon in 3 sizes, used to mark anything an agent touched */
function AgentMark({size = 'md'}){
  const sz = size === 'sm' ? 10 : size === 'lg' ? 20 : 14;
  return (
    <span className={`agent-mark agent-mark--${size}`}>
      <Icon name="sparkle" size={sz} fill="currentColor"/>
    </span>
  );
}

/* (2) ConfidencePill — colored % chip */
function ConfidencePill({value}){
  const level = value >= 85 ? 'ok' : value >= 60 ? 'warn' : 'low';
  return <span className={`conf-pill conf-pill--${level}`}>{value}%</span>;
}

/* (3) AnnotationStrip — inline summary of what an agent did, with "почему?" link */
function AnnotationStrip({agent, summary, traceId, artifactsCount, confidence, onWhy}){
  return (
    <div className="annotation-strip">
      <AgentMark size="sm"/>
      <span>
        <strong style={{color:'var(--tx)'}}>{agent}</strong>: {summary}
      </span>
      {confidence != null && <ConfidencePill value={confidence}/>}
      <span style={{flex:1}}/>
      {onWhy && <span className="as-link" onClick={() => onWhy(traceId)}>почему?</span>}
      {artifactsCount > 0 && <span>· артефакты ({artifactsCount})</span>}
    </div>
  );
}

/* (4) EscalationBanner — pulsing dot + reason + open button */
function EscalationBanner({agent, dealId, reason, onOpen, severity = 'warn'}){
  return (
    <div className={`escalation-banner ${severity === 'red' ? 'escalation-banner--red' : ''}`}>
      <span className="eb-dot"/>
      <span>
        <strong>{agent}</strong> просит подтверждения · <code style={{fontFamily:'JetBrains Mono, monospace', fontSize:12}}>{dealId}</code> · {reason}
      </span>
      <span style={{flex:1}}/>
      <button className="btn btn-sm btn-outline" onClick={onOpen}>открыть</button>
    </div>
  );
}

/* (5) LivePulse — tiny breathing dot used to indicate live agent activity */
function LivePulse(){
  return <span className="live-pulse" aria-hidden="true"/>;
}

window.AgentMark = AgentMark;
window.ConfidencePill = ConfidencePill;
window.AnnotationStrip = AnnotationStrip;
window.EscalationBanner = EscalationBanner;
window.LivePulse = LivePulse;
