
import React from 'react';
import { inherits } from 'util';

export enum Theme {
  Light = 'light',
  Dark = 'dark',
  System = 'system',
}

export interface Employee {
  id: string;
  name: string;
  email: string;
  role?: string; // Remove 'owner' from the union type since employees are never owners
  department?: string | 'General';
  joinedAt?: number;
  status: 'invited' | 'active';
  initials?: string;
  inviteCode?: string;
}


export interface UserOrganization {
  orgId: string;
  name: string;
  role: 'owner' | 'admin' | 'employee';
  onboardingCompleted: boolean;
  joinedAt: number;
}

export interface OnboardingData {
  yourName: string;
  companyLogo: string;
  companyName: string;

  companySize: number;
  mission: string;
  missionEvolution: string;
  vision: string;
  strategicAdvantages: string;
  vulnerabilities: string;
  scalabilityChallenges: string;
  growthLimitations: string;

  leadershipStructure: string;
  criticalPeople: string;
  leadershipGaps: string;
  delegationOpportunities: string;
  leadershipDevelopment: string;
  heldOntoTooLong: string;
  successionConfidence: string;

  businessSystems: string;
  personalDependencies: string;
  operationalFriction: string;
  workflowEfficiency: string;
  fragileProcesses: string;
  recurringProblems: string;

  cultureDescription: string;
  livedValues: string;
  internalFriction: string;
  speakUpCulture: string;
  clearExpectations: string;
  staffFeedback: string;
  highPerformerLove: string;

  revenuePipeline: string;
  customerAcquisition: string;
  customerAcquisitionCost: string;
  customerLifetimeValue: string;
  underutilizedChannels: string;
  overspendingROI: string;
  currentBottleneck: string;

  monthlyBurnOverhead: string;
  currentRevenue: string;
  netProfitMargin: string;
  financialsUpToDate: string;
  financialGrowthPlanning: string;
  cashRunway: string;
  underpricing: string;

  uniqueOffering: string;
  productStagnation: string;
  industryTrends: string;
  innovationAhead: string;
  industryDirection: string;

  avoidedDecisions: string;
  hardestCall: string;
  energyDrain: string;
  leadershipStretched: string;
  sabbaticalRisks: string;
  companyLegacy: string;
  yearSuccess: number;
}

export interface Organization {
  name: string;
  createdAt: number;
  updatedAt: number;
  onboardingCompleted: boolean;
  ownerId: string;
  ownerInfo?: {
    id: string;
    name: string;
    email: string;
    joinedAt: number;
  };
  // Subscription fields (will be populated after Stripe setup)
  subscription: {
    status: 'trial' | 'active' | 'past_due' | 'canceled';
    stripeCustomerId: string | null;
    stripeSubscriptionId: string | null;
    currentPeriodStart: number | null;
    currentPeriodEnd: number | null;
    trialEnd: number | null;
  };
  // Usage tracking
  usage: {
    employeeCount: number;
    reportsGenerated: number;
    lastReportGeneration: number | null;
  };
  // Organization settings
  settings: {
    allowedEmployeeCount: number;
    featuresEnabled: {
      aiReports: boolean;
      chat: boolean;
      analytics: boolean;
    }
  };
  onboardingData?: OnboardingData;
}

export interface EmployeeReport {
  employeeId: string;
  department: string;
  role: string;
  roleAndOutput: {
    responsibilities: string;
    clarityOnRole: string;
    selfRatedOutput: string;
    recurringTasks: string;
  };
  insights: {
    personalityTraits: string;
    psychologicalIndicators: string[];
    selfAwareness: string;
    emotionalResponses: string;
    growthDesire: string;
  };
  strengths: string[];
  weaknesses: string[];
  opportunities: {
    title: string;
    description: string;
  }[];
  risks: string[];
  recommendations: string[];
  gradingOverview: {
    employeeName: string;
    grade: string;
    reliability: number;
    roleFit: number;
    scalability: number;
    output: number;
    initiative: number;
  };
}

export interface Submission {
  employeeId: string;
  answers: {
    question: string;
    answer: string;
  }[];
}

export interface FaqItem {
  question: string;
  answer: string;
}

export interface NavItem {
  href: string;
  label: string;
  icon: (props: { className?: string }) => React.ReactNode;
}

export interface ChatMessage {
  id: string;
  role: 'user' | 'assistant';
  text: string;
  isLoading?: boolean;
}

export interface CompanyReport {
  id: string;
  createdAt: number;
  overview: {
    totalEmployees: number;
    departmentBreakdown: { department: string; count: number; }[];
    submissionRate: number; // percentage of employees who submitted
    lastUpdated: number;
    // Optional aggregate metrics
    averagePerformanceScore?: number;
    riskLevel?: 'Low' | 'Medium' | 'High';
  };
  weaknesses: {
    title: string;
    description: string;
  }[];
  // Personnel lifecycle - Categories should be Promoted, Reassigned, Fired
  personnelChanges: {
    newHires: { name: string; department: string; role: string; impact?: string }[]; // Is the reassignments?
    promotions: { name: string; fromRole: string; toRole: string; impact?: string }[];
    departures: { name: string; department: string; reason: string; impact?: string }[];
  };
  // Hiring / talent gaps
  immediateHiringNeeds: { // Needs to be used!!
    department: string;
    role: string;
    priority: 'High' | 'Medium' | 'Low';
    reasoning: string;
    urgency?: 'high' | 'medium' | 'low'; // UI alias
  }[];
  forwardOperatingPlan?: {
    title: string;
    details: string[];
  }[];
  strengths: string[];
  organizationalImpactSummary?: {
    category: 'Mission Critical' | 'Highly Valuable' | 'Core Support' | 'Low Criticality';
    employees: {
      employeeName: string;
      impact: string;
      description: string;
      suggestedPay: string;
    }[];
  }[];
  // Grading: array + map for UI
  gradingBreakdown: {
    departmentNameShort: string; // For the tab label
    departmentName: string;
    lead: string; // Team lead
    support: string; // Team leads' support person
    departmentGrade: string;
    executiveSummary: string;
    teamScores: {
      employeeName: string;
      grade: string;
      reliability: number;
      roleFit: number;
      scalability: number;
      output: number;
      initiative: number;
    }[];
  }[];
  executiveSummary: string;
}

export interface CompanyReportSummary {
  id: string;
  createdAt: number;
  summary: string; // For backwards compatibility
}