import type { BrandProfile, Project, PostSequenceItem } from "@/types/workflow";
import type { StoryArcBeat } from "../story-types";

/** Canonical NCERT "A Letter to God" narrative beat — human story DNA. */
export interface LetterToGodBeat {
  index: number;
  title: string;
  situation: string;
  conflict: string;
  emotion: string[];
  lesson: string;
  visualMood: string;
}

export interface BrandIntelligence {
  companyName: string;
  tagline: string;
  industry: string;
  brandVoice: string;
  website: string;
  targetMarkets: string;
  timezone: string;
  mission: string;
  brandPromise: string;
  uniqueSellingProposition: string;
  toneOfVoice: string;
  writingStyle: string;
  /** Scraped homepage services — used for image/video branding */
  primaryService?: string;
  services?: Array<{ label: string; detail: string }>;
  websiteScraped?: boolean;
}

export interface StoryIntelligence {
  beatIndex: number;
  totalBeats: number;
  act: string;
  title: string;
  campaignStory: string;
  currentSituation: string;
  conflict: string;
  obstacle: string;
  turningPoint: string;
  solution: string;
  transformation: string;
  lesson: string;
  emotions: string[];
  letterToGodBeat: LetterToGodBeat;
  engagementQuestion: string;
  keyTheme: string;
  narrativeBridge: { from: string; to: string };
}

export interface HumanWritingDNA {
  principles: string[];
  avoid: string[];
}

export interface EngagementIntelligence {
  desiredResults: string[];
  conversationType: string;
  primaryCta: string;
}

export interface CreativeIntelligence {
  humanWriting: HumanWritingDNA;
  emotions: string[];
  engagement: EngagementIntelligence;
  authenticity: string[];
}

export interface PlatformIntelligence {
  platform: string;
  tone: string;
  format: string;
  strengths: string[];
}

export interface VisualIntelligence {
  photographyStyle: string;
  mood: string;
  lighting: string;
  colorPalette: string;
  composition: string;
  people: string;
  expressions: string;
  aspectRatio: string;
}

export interface VideoIntelligence {
  openingHook: string;
  storyTimeline: string;
  scenes: string[];
  musicMood: string;
  voiceTone: string;
  endingEmotion: string;
  cta: string;
}

export interface MasterContextInput {
  projectId: string;
  project: Project;
  brand: BrandProfile;
  sequenceItem: PostSequenceItem;
  creativeBrief: string;
  beatIndex: number;
  beat?: StoryArcBeat;
  schedule?: { postsPerDay: 1 | 2; saved: boolean };
  automation?: Record<string, boolean>;
  connectedPlatforms?: string[];
}

export interface MasterContext {
  creativeBrief: string;
  brand: BrandIntelligence;
  story: StoryIntelligence;
  creative: CreativeIntelligence;
  platforms: PlatformIntelligence[];
  visual: VisualIntelligence;
  video: VideoIntelligence;
  markdown: string;
}
