/**
 * Tipos consumidos pelo frontend — vem da API, nao validados via Zod aqui.
 * Validacao mora no backend (runtime/src/types/flow.ts).
 */

export type BotMeta = {
  bot_name: string;
  bot_slug: string;
  archetype: "vendedora" | "diagnostico" | "qualificador" | "custom";
  theme: Theme;
};

export type Theme = {
  primary_color: string;
  secondary_color: string;
  bg_dark?: string;
  text_on_primary: string;
  avatar_letter?: string;
  font: string;
  layout: "centered" | "chat-classic" | "fullscreen";
};

export type RenderableBlock =
  | { id: string; type: "text"; data: { content: string; delay_ms?: number; next?: string } }
  | { id: string; type: "image"; data: { url: string; alt: string; next?: string } }
  | { id: string; type: "video"; data: { url: string; autoplay: boolean; next?: string } }
  | { id: string; type: "input_text"; data: { prompt: string; placeholder?: string; var: string; validation?: { min_length?: number; max_length?: number } } }
  | { id: string; type: "input_email"; data: { prompt: string; var: string } }
  | { id: string; type: "input_phone"; data: { prompt: string; var: string; country_default: string } }
  | { id: string; type: "choice"; data: { prompt: string; options: Array<{ label: string; value: string; next: string }> } }
  | { id: string; type: "multi_choice"; data: { prompt: string; options: Array<{ label: string; value: string }> } }
  | { id: string; type: "ai"; data: { system_prompt: string; max_turns: number; exit_intents: Array<{ intent: string; next: string }>; fallback: string } };

export type EngineStep =
  | { kind: "render"; block: RenderableBlock }
  | { kind: "complete"; redirect?: { url: string } };

export type Message = {
  role: "bot" | "user";
  content: string;
  block_id?: string;
  ts: number;
};
