
export enum EntityType {
  CHARACTER = 'Personnage',
  LOCATION = 'Lieu',
  OBJECT = 'Objet',
  NOTE = 'Note'
}

export interface CharacterAttributes {
  age: number;
  height: number;
  hair: string;
  eyes: string;
  archetype: string;
  role: 'protagonist' | 'antagonist' | 'support' | 'extra';
  personality: {
    spectrumIntrovertExtravert: number;
    spectrumEmotionalRational: number;
    spectrumChaoticLawful: number;
  };
  physicalQuirk: string;
  behavioralQuirk: string;
}

export type CustomFieldType = 'text' | 'textarea' | 'number' | 'boolean' | 'select';

export interface CustomFieldDefinition {
  id: string;
  label: string;
  type: CustomFieldType;
  options?: string[];
  placeholder?: string;
}

export interface EntityTemplate {
  entityType: EntityType;
  fields: CustomFieldDefinition[];
}

export interface Entity {
  id: string;
  type: EntityType;
  name: string;
  description: string;
  details: string;
  storyContext?: string;
  attributes?: CharacterAttributes;
  customValues?: Record<string, any>;
}

export interface Chapter {
  id: string;
  title: string;
  content: string;
  summary?: string;
}

export type PlotNodeType = 'story' | 'dialogue' | 'action';

export interface PlotNode {
  id: string;
  x: number;
  y: number;
  title: string;
  description: string;
  color: string;
  type?: PlotNodeType;
}

export interface PlotConnection {
  id: string;
  source: string;
  target: string;
}

export interface WorkflowData {
  nodes: PlotNode[];
  connections: PlotConnection[];
}

export type IdeaStatus = 'todo' | 'progress' | 'done';
export type IdeaCategory = 'plot' | 'character' | 'research' | 'todo';

export interface Idea {
  id: string;
  title: string;
  description: string;
  status: IdeaStatus;
  category: IdeaCategory;
  createdAt: number;
}

export interface BookSettings {
  genre: string;
  subGenre?: string;
  targetAudience: string;
  tone: string;
  pov: string;
  tense: string;
  synopsis: string;
  themes: string;
}

export interface BookProject {
  id: string;
  title: string;
  author: string;
  lastModified: number;
  settings?: BookSettings;
  // Direct fields sometimes used in creation/updates before settings normalization
  genre?: string;
  pov?: string;
  tense?: string;
  chapters: Chapter[];
  entities: Entity[];
  workflow?: WorkflowData;
  templates?: EntityTemplate[];
  styleGuide?: string;
  ideas?: Idea[];
}

export interface ChatMessage {
  id: string;
  role: 'user' | 'model';
  text: string;
  responseType?: 'draft' | 'reflection';
  isLoading?: boolean;
}

// --- SAAS TYPES ---

export interface PlanData {
  id: string;
  name: string;
  displayName: string;
  price: number;
  description: string;
  features: string[];
  isPopular: boolean;
  maxProjects: number;
  maxAiActions: number;
}

export interface Subscription {
  plan: string; // The ID of the plan
  planDetails?: PlanData; // The populated plan details from DB
  startDate: number;
  status: 'active' | 'canceled' | 'past_due';
}

export interface UserUsage {
  aiActionsCurrent: number;
  aiActionsLimit: number;
  projectsLimit: number;
}

export interface UserPreferences {
  theme: 'light' | 'dark' | 'sepia';
  dailyWordGoal: number;
  language: 'fr' | 'en';
}

export interface UserStats {
  totalWordsWritten: number;
  writingStreak: number;
  lastWriteDate: number;
}

export interface UserProfile {
  id: string;
  email: string;
  name: string;
  avatar?: string;
  bio?: string;
  subscription: Subscription;
  usage: UserUsage;
  preferences: UserPreferences;
  stats: UserStats;
}

export type ViewMode = 'write' | 'world_building' | 'workflow' | 'settings' | 'preview' | 'ideas' | 'landing' | 'features' | 'pricing' | 'checkout' | 'dashboard' | 'auth' | 'signup' | 'profile';
