export type NodeKind =
  | "start"
  | "message"
  | "buttons"
  | "condition"
  | "wait"
  | "end"
  | "sentiment"   // Feature 6: routes by patient mood
  | "save_var"    // Feature 7: saves patient reply to variable
  | "retry";      // Feature 8: smart retry gate

export interface ButtonOption {
  id: string;
  label: string;
  text: string;
}

export interface ConditionBranch {
  id: string;
  label: string;
  keywords: string[];
  aiHint: string;
}

export interface NodeData {
  kind: NodeKind;
  label: string;
  content?: string;
  buttons?: ButtonOption[];
  branches?: ConditionBranch[];
  delayMinutes?: number;
  selected?: boolean;
  generating?: boolean;
  // save_var
  varName?: string;
  varPrompt?: string;
  // retry
  retryDelayMinutes?: number;
  maxRetries?: number;
  retryMessage?: string;
  // analytics overlay
  analytics?: { sent: number; responded: number; dropped: number };
}

export interface NodeMeta {
  color: string;
  light: string;
  border: string;
  icon: string;
  label: string;
  description: string;
  gradient: string;
}

export const KIND_META: Record<NodeKind, NodeMeta> = {
  start: {
    color: "#6366f1", light: "#eef2ff", border: "#c7d2fe",
    icon: "⚡", label: "Trigger", description: "Where the conversation starts",
    gradient: "from-indigo-500 to-violet-500",
  },
  message: {
    color: "#0284c7", light: "#e0f2fe", border: "#bae6fd",
    icon: "💬", label: "Send Message", description: "Send a WhatsApp text",
    gradient: "from-sky-500 to-blue-500",
  },
  buttons: {
    color: "#059669", light: "#d1fae5", border: "#a7f3d0",
    icon: "🔘", label: "Give Choices", description: "Ask patient to pick one option",
    gradient: "from-emerald-500 to-teal-500",
  },
  condition: {
    color: "#d97706", light: "#fef3c7", border: "#fde68a",
    icon: "🔀", label: "Smart Branch", description: "Route based on patient's answer",
    gradient: "from-amber-500 to-orange-500",
  },
  wait: {
    color: "#475569", light: "#f1f5f9", border: "#cbd5e1",
    icon: "⏳", label: "Wait / Delay", description: "Pause before the next step",
    gradient: "from-slate-500 to-slate-600",
  },
  end: {
    color: "#dc2626", light: "#fee2e2", border: "#fecaca",
    icon: "✅", label: "End Flow", description: "Mark the conversation complete",
    gradient: "from-rose-500 to-red-500",
  },
  sentiment: {
    color: "#ec4899", light: "#fdf2f8", border: "#fbcfe8",
    icon: "❤️‍🔥", label: "Mood Router", description: "Route by patient sentiment",
    gradient: "from-pink-500 to-rose-500",
  },
  save_var: {
    color: "#0891b2", light: "#ecfeff", border: "#a5f3fc",
    icon: "🧠", label: "Remember Answer", description: "Save patient reply as variable",
    gradient: "from-cyan-500 to-sky-500",
  },
  retry: {
    color: "#9333ea", light: "#f3e8ff", border: "#e9d5ff",
    icon: "🔄", label: "Smart Retry", description: "Follow up if no response",
    gradient: "from-purple-500 to-fuchsia-500",
  },
};
