/**
 * Complete 63-step onboarding configuration based on Figma designs
 */
import { OnboardingData } from "../types";


export interface OnboardingStep {
  id: number;
  section: number;
  sectionName: string;
  sectionPosition: number; // position within the section (1 of 8, 2 of 8, etc.)
  totalInSection: number;
  type: 'intro' | 'question' | 'multiple_choice' | 'form';
  title: string;
  description?: string;
  placeholder?: string;
  options?: string[];
  field?: string; // field name for form data
  required?: boolean;
  rows?: number; // for textarea
}

export interface OnboardingFormData extends OnboardingData {
  companyName: string;
  yourName: string;
  companyLogo: string;
}

export const initializeOnboardingData = (): OnboardingFormData => {
  const data = {
    // Ensure required form fields are initialized
    companyName: '',
    yourName: '',
    companyLogo: '',
  };
  onboardingSteps.forEach(step => {
    if (step.field) {
      if (step.type === 'multiple_choice' && step.options) {
        data[step.field] = '';
      } else {
        data[step.field] = '';
      }
    }
  });
  return data as OnboardingFormData;
};

export const onboardingSteps: OnboardingStep[] = [
  // Section 1: Company Overview & Mission (Steps 1-10)
  {
    id: 1,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 1,
    totalInSection: 9,
    type: 'form',
    title: 'Company Details',
    field: 'companyDetails',
    required: true
  },
  {
    id: 2,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 1,
    totalInSection: 9,
    type: 'intro',
    title: 'Company Overview & Mission.',
    description: 'Description about the topic and what it means.'
  },
  {
    id: 3,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 2,
    totalInSection: 9,
    type: 'multiple_choice',
    title: 'How many people work at [Company Name]?',
    options: ['1-10', '10-25', '25-50', '50-100', '100+'],
    field: 'companySize',
    required: true
  },
  {
    id: 4,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 3,
    totalInSection: 9,
    type: 'question',
    title: 'What is the mission of your company?',
    placeholder: 'Type your answer....',
    field: 'mission',
    required: true,
    rows: 6
  },
  {
    id: 5,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 4,
    totalInSection: 9,
    type: 'question',
    title: 'How has your mission evolved in the last 1–3 years?',
    placeholder: 'Type your answer....',
    field: 'missionEvolution',
    required: true,
    rows: 6
  },
  {
    id: 6,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 5,
    totalInSection: 9,
    type: 'question',
    title: 'What is your 5-year vision for the company?',
    placeholder: 'Type your answer....',
    field: 'vision',
    required: true,
    rows: 6
  },
  {
    id: 7,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 6,
    totalInSection: 9,
    type: 'question',
    title: 'What are your company\'s top 3 strategic advantages?',
    placeholder: 'Type your answer....',
    field: 'strategicAdvantages',
    required: true,
    rows: 6
  },
  {
    id: 8,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 7,
    totalInSection: 9,
    type: 'question',
    title: 'What are the biggest vulnerabilities or threats?',
    placeholder: 'Type your answer....',
    field: 'vulnerabilities',
    required: true,
    rows: 6
  },
  {
    id: 9,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 8,
    totalInSection: 9,
    type: 'question',
    title: 'If the business were to double in size tomorrow, what would break first?',
    placeholder: 'Type your answer....',
    field: 'scalabilityChallenges',
    required: true,
    rows: 6
  },
  {
    id: 10,
    section: 1,
    sectionName: "Company Overview & Mission",
    sectionPosition: 9,
    totalInSection: 9,
    type: 'question',
    title: 'What is currently limiting your company\'s growth?',
    placeholder: 'Type your answer....',
    field: 'growthLimitations',
    required: true,
    rows: 6
  },

  // Section 2: Leadership & Organizational Structure (Steps 11-18)
  {
    id: 11,
    section: 2,
    sectionName: "Leadership & Organizational Structure",
    sectionPosition: 1,
    totalInSection: 8,
    type: 'intro',
    title: 'Leadership & Organizational Structure',
    description: 'Description about the topic and what it means.'
  },
  {
    id: 12,
    section: 2,
    sectionName: "Leadership & Organizational Structure",
    sectionPosition: 2,
    totalInSection: 8,
    type: 'question',
    title: 'Describe your current leadership structure.',
    placeholder: 'Type your answer....',
    field: 'leadershipStructure',
    required: true,
    rows: 6
  },
  {
    id: 13,
    section: 2,
    sectionName: "Leadership & Organizational Structure",
    sectionPosition: 3,
    totalInSection: 8,
    type: 'question',
    title: 'Who are the most critical people in the business today?',
    placeholder: 'Type your answer....',
    field: 'criticalPeople',
    required: true,
    rows: 6
  },
  {
    id: 14,
    section: 2,
    sectionName: "Leadership & Organizational Structure",
    sectionPosition: 4,
    totalInSection: 8,
    type: 'question',
    title: 'Where are leadership gaps or weak links?',
    placeholder: 'Type your answer....',
    field: 'leadershipGaps',
    required: true,
    rows: 6
  },
  {
    id: 15,
    section: 2,
    sectionName: "Leadership & Organizational Structure",
    sectionPosition: 5,
    totalInSection: 8,
    type: 'question',
    title: 'What decisions are you still involved in that someone else should own?',
    placeholder: 'Type your answer....',
    field: 'delegationOpportunities',
    required: true,
    rows: 6
  },
  {
    id: 16,
    section: 2,
    sectionName: "Leadership & Organizational Structure",
    sectionPosition: 6,
    totalInSection: 8,
    type: 'question',
    title: 'How do you develop internal leaders?',
    placeholder: 'Type your answer....',
    field: 'leadershipDevelopment',
    required: true,
    rows: 6
  },
  {
    id: 17,
    section: 2,
    sectionName: "Leadership & Organizational Structure",
    sectionPosition: 7,
    totalInSection: 8,
    type: 'question',
    title: 'Are there roles or people you\'ve held onto too long?',
    placeholder: 'Type your answer....',
    field: 'heldOntoTooLong',
    required: true,
    rows: 6
  },
  {
    id: 18,
    section: 2,
    sectionName: "Leadership & Organizational Structure",
    sectionPosition: 8,
    totalInSection: 8,
    type: 'question',
    title: 'How confident are you in your succession or delegation plan?',
    placeholder: 'Type your answer....',
    field: 'successionConfidence',
    required: true,
    rows: 6
  },

  // Section 3: Operations & Execution (Steps 19-25)
  {
    id: 19,
    section: 3,
    sectionName: "Operations & Execution",
    sectionPosition: 1,
    totalInSection: 7,
    type: 'intro',
    title: 'Operations & Execution',
    description: 'Description about the topic and what it means.'
  },
  {
    id: 20,
    section: 3,
    sectionName: "Operations & Execution",
    sectionPosition: 2,
    totalInSection: 7,
    type: 'question',
    title: 'What systems or tools do you rely on to run the business?',
    placeholder: 'Type your answer....',
    field: 'businessSystems',
    required: true,
    rows: 6
  },
  {
    id: 21,
    section: 3,
    sectionName: "Operations & Execution",
    sectionPosition: 3,
    totalInSection: 7,
    type: 'question',
    title: 'Where does the business rely too much on you personally?',
    placeholder: 'Type your answer....',
    field: 'personalDependencies',
    required: true,
    rows: 6
  },
  {
    id: 22,
    section: 3,
    sectionName: "Operations & Execution",
    sectionPosition: 4,
    totalInSection: 7,
    type: 'question',
    title: 'Where is the most operational friction inside the company?',
    placeholder: 'Type your answer....',
    field: 'operationalFriction',
    required: true,
    rows: 6
  },
  {
    id: 23,
    section: 3,
    sectionName: "Operations & Execution",
    sectionPosition: 5,
    totalInSection: 7,
    type: 'question',
    title: 'How efficient is your workflow from sales to delivery?',
    placeholder: 'Type your answer....',
    field: 'workflowEfficiency',
    required: true,
    rows: 6
  },
  {
    id: 24,
    section: 3,
    sectionName: "Operations & Execution",
    sectionPosition: 6,
    totalInSection: 7,
    type: 'question',
    title: 'What processes feel fragile or inconsistent?',
    placeholder: 'Type your answer....',
    field: 'fragileProcesses',
    required: true,
    rows: 6
  },
  {
    id: 25,
    section: 3,
    sectionName: "Operations & Execution",
    sectionPosition: 7,
    totalInSection: 7,
    type: 'question',
    title: 'What recurring problems never seem to get solved?',
    placeholder: 'Type your answer....',
    field: 'recurringProblems',
    required: true,
    rows: 6
  },

  // Section 4: Culture & Team Health (Steps 26-33)
  {
    id: 26,
    section: 4,
    sectionName: "Culture & Team Health",
    sectionPosition: 1,
    totalInSection: 8,
    type: 'intro',
    title: 'Culture & Team Health',
    description: 'Description about the topic and what it means.'
  },
  {
    id: 27,
    section: 4,
    sectionName: "Culture & Team Health",
    sectionPosition: 2,
    totalInSection: 8,
    type: 'question',
    title: 'How would you describe your company culture in a few words?',
    placeholder: 'Type your answer....',
    field: 'cultureDescription',
    required: true,
    rows: 6
  },
  {
    id: 28,
    section: 4,
    sectionName: "Culture & Team Health",
    sectionPosition: 3,
    totalInSection: 8,
    type: 'question',
    title: 'What values are truly lived out daily by your team?',
    placeholder: 'Type your answer....',
    field: 'livedValues',
    required: true,
    rows: 6
  },
  {
    id: 29,
    section: 4,
    sectionName: "Culture & Team Health",
    sectionPosition: 4,
    totalInSection: 8,
    type: 'question',
    title: 'Where is there internal friction or misalignment?',
    placeholder: 'Type your answer....',
    field: 'internalFriction',
    required: true,
    rows: 6
  },
  {
    id: 30,
    section: 4,
    sectionName: "Culture & Team Health",
    sectionPosition: 5,
    totalInSection: 8,
    type: 'question',
    title: 'Do people speak up when things are broken or wrong?',
    placeholder: 'Type your answer....',
    field: 'speakUpCulture',
    required: true,
    rows: 6
  },
  {
    id: 31,
    section: 4,
    sectionName: "Culture & Team Health",
    sectionPosition: 6,
    totalInSection: 8,
    type: 'question',
    title: 'Are people clear on expectations and priorities?',
    placeholder: 'Type your answer....',
    field: 'clearExpectations',
    required: true,
    rows: 6
  },
  {
    id: 32,
    section: 4,
    sectionName: "Culture & Team Health",
    sectionPosition: 7,
    totalInSection: 8,
    type: 'question',
    title: 'What feedback have you heard recently from staff that stuck with you?',
    placeholder: 'Type your answer....',
    field: 'staffFeedback',
    required: true,
    rows: 6
  },
  {
    id: 33,
    section: 4,
    sectionName: "Culture & Team Health",
    sectionPosition: 8,
    totalInSection: 8,
    type: 'question',
    title: 'What do high-performers love most about working for you?',
    placeholder: 'Type your answer....',
    field: 'highPerformerLove',
    required: true,
    rows: 6
  },

  // Section 5: Sales, Marketing & Growth (Steps 34-42)
  {
    id: 34,
    section: 5,
    sectionName: "Sales, Marketing & Growth",
    sectionPosition: 1,
    totalInSection: 8,
    type: 'intro',
    title: 'Sales, Marketing & Growth',
    description: 'Description about the topic and what it means.'
  },
  {
    id: 35,
    section: 5,
    sectionName: "Sales, Marketing & Growth",
    sectionPosition: 2,
    totalInSection: 8,
    type: 'question',
    title: 'How consistent is your revenue pipeline?',
    placeholder: 'Type your answer....',
    field: 'revenuePipeline',
    required: true,
    rows: 6
  },
  {
    id: 36,
    section: 5,
    sectionName: "Sales, Marketing & Growth",
    sectionPosition: 3,
    totalInSection: 8,
    type: 'question',
    title: 'Where do most of your customers come from?',
    placeholder: 'Type your answer....',
    field: 'customerAcquisition',
    required: true,
    rows: 6
  },
  {
    id: 37,
    section: 5,
    sectionName: "Sales, Marketing & Growth",
    sectionPosition: 4,
    totalInSection: 8,
    type: 'question',
    title: 'What is your customer acquisition cost (CAC)?',
    placeholder: 'Type your answer....',
    field: 'customerAcquisitionCost',
    required: true,
    rows: 6
  },
  {
    id: 38,
    section: 5,
    sectionName: "Sales, Marketing & Growth",
    sectionPosition: 5,
    totalInSection: 8,
    type: 'question',
    title: 'What\'s your average customer lifetime value (LTV)?',
    placeholder: 'Type your answer....',
    field: 'customerLifetimeValue',
    required: true,
    rows: 6
  },
  {
    id: 39,
    section: 5,
    sectionName: "Sales, Marketing & Growth",
    sectionPosition: 6,
    totalInSection: 8,
    type: 'question',
    title: 'What channels or strategies are underutilized?',
    placeholder: 'Type your answer....',
    field: 'underutilizedChannels',
    required: true,
    rows: 6
  },
  {
    id: 40,
    section: 5,
    sectionName: "Sales, Marketing & Growth",
    sectionPosition: 7,
    totalInSection: 8,
    type: 'question',
    title: 'Where are you overspending with low ROI?',
    placeholder: 'Type your answer....',
    field: 'overspendingROI',
    required: true,
    rows: 6
  },
  {
    id: 41,
    section: 5,
    sectionName: "Sales, Marketing & Growth",
    sectionPosition: 8,
    totalInSection: 8,
    type: 'question',
    title: 'What is your current bottleneck in scaling revenue?',
    placeholder: 'Type your answer....',
    field: 'currentBottleneck',
    required: true,
    rows: 6
  },

  // Section 6: Financial Health & Metrics
  {
    id: 42,
    section: 6,
    sectionName: "Financial Health & Metrics",
    sectionPosition: 1,
    totalInSection: 8,
    type: 'intro',
    title: 'Financial Health & Metrics',
    description: 'Description about the topic and what it means.'
  },
  {
    id: 43,
    section: 6,
    sectionName: "Financial Health & Metrics",
    sectionPosition: 2,
    totalInSection: 8,
    type: 'question',
    title: 'What is your monthly burn or overhead?',
    placeholder: 'Type your answer....',
    field: 'monthlyBurnOverhead',
    required: true,
    rows: 6
  },
  {
    id: 44,
    section: 6,
    sectionName: "Financial Health & Metrics",
    sectionPosition: 3,
    totalInSection: 8,
    type: 'question',
    title: 'What is your current monthly/annual revenue?',
    placeholder: 'Type your answer....',
    field: 'currentRevenue',
    required: true,
    rows: 6
  },
  {
    id: 45,
    section: 6,
    sectionName: "Financial Health & Metrics",
    sectionPosition: 4,
    totalInSection: 8,
    type: 'question',
    title: 'What is your current net profit margin?',
    placeholder: 'Type your answer....',
    field: 'netProfitMargin',
    required: true,
    rows: 6
  },
  {
    id: 46,
    section: 6,
    sectionName: "Financial Health & Metrics",
    sectionPosition: 5,
    totalInSection: 8,
    type: 'question',
    title: 'Are your financials up to date and properly reported?',
    placeholder: 'Type your answer....',
    field: 'financialsUpToDate',
    required: true,
    rows: 6
  },
  {
    id: 47,
    section: 6,
    sectionName: "Financial Health & Metrics",
    sectionPosition: 6,
    totalInSection: 8,
    type: 'question',
    title: 'What would your team do differently if they had full financial transparency?',
    placeholder: 'Type your answer....',
    field: 'financialGrowthPlanning',
    required: true,
    rows: 6
  },
  {
    id: 48,
    section: 6,
    sectionName: "Financial Health & Metrics",
    sectionPosition: 7,
    totalInSection: 8,
    type: 'question',
    title: 'What does your cash runway look like?',
    placeholder: 'Type your answer....',
    field: 'cashRunway',
    required: true,
    rows: 6
  },
  {
    id: 49,
    section: 6,
    sectionName: "Financial Health & Metrics",
    sectionPosition: 8,
    totalInSection: 8,
    type: 'question',
    title: 'What are you underpricing or undervaluing?',
    placeholder: 'Type your answer....',
    field: 'underpricing',
    required: true,
    rows: 6
  },

  // Section 7: Innovation & Product/Service Strategy (Steps 43-53)
  {
    id: 50,
    section: 7,
    sectionName: "Innovation & Product/Service Strategy",
    sectionPosition: 1,
    totalInSection: 6,
    type: 'intro',
    title: 'Innovation & Product/Service Strategy',
    description: 'Description about the topic and what it means.'
  },
  {
    id: 51,
    section: 7,
    sectionName: "Innovation & Product/Service Strategy",
    sectionPosition: 2,
    totalInSection: 6,
    type: 'question',
    title: 'What is your most unique offering?',
    placeholder: 'Type your answer....',
    field: 'uniqueOffering',
    required: true,
    rows: 6
  },
  {
    id: 52,
    section: 7,
    sectionName: "Innovation & Product/Service Strategy",
    sectionPosition: 3,
    totalInSection: 6,
    type: 'question',
    title: 'What part of the product/service is outdated or stagnant?',
    placeholder: 'Type your answer....',
    field: 'productStagnation',
    required: true,
    rows: 6
  },
  {
    id: 53,
    section: 7,
    sectionName: "Innovation & Product/Service Strategy",
    sectionPosition: 4,
    totalInSection: 6,
    type: 'question',
    title: 'What trends are you tracking in your industry?',
    placeholder: 'Type your answer....',
    field: 'industryTrends',
    required: true,
    rows: 6
  },
  {
    id: 54,
    section: 7,
    sectionName: "Innovation & Product/Service Strategy",
    sectionPosition: 5,
    totalInSection: 6,
    type: 'question',
    title: 'How does your company stay ahead of innovation?',
    placeholder: 'Type your answer....',
    field: 'innovationAhead',
    required: true,
    rows: 6
  },
  {
    id: 55,
    section: 7,
    sectionName: "Innovation & Product/Service Strategy",
    sectionPosition: 6,
    totalInSection: 6,
    type: 'question',
    title: 'What new product/service do you believe could change the game for you?',
    placeholder: 'Type your answer....',
    field: 'industryDirection',
    required: true,
    rows: 6
  },


  // Section 8: Personal Leadership & Risk
  {
    id: 54,
    section: 8,
    sectionName: "Personal Leadership & Risk",
    sectionPosition: 1,
    totalInSection: 8,
    type: 'intro',
    title: 'Personal Leadership & Risk',
    description: 'Description about the topic and what it means.'
  },
  {
    id: 55,
    section: 8,
    sectionName: "Personal Leadership & Risk",
    sectionPosition: 2,
    totalInSection: 8,
    type: 'question',
    title: 'What decisions are you avoiding right now?',
    placeholder: 'Type your answer....',
    field: 'avoidedDecisions',
    required: true,
    rows: 6
  },
  {
    id: 56,
    section: 8,
    sectionName: "Personal Leadership & Risk",
    sectionPosition: 3,
    totalInSection: 8,
    type: 'question',
    title: 'What\'s been the hardest call you\'ve had to make in the last year?',
    placeholder: 'Type your answer....',
    field: 'hardestCall',
    required: true,
    rows: 6
  },
  {
    id: 57,
    section: 8,
    sectionName: "Personal Leadership & Risk",
    sectionPosition: 4,
    totalInSection: 8,
    type: 'question',
    title: 'What part of the business drains your energy the most?',
    placeholder: 'Type your answer....',
    field: 'energyDrain',
    required: true,
    rows: 6
  },
  {
    id: 58,
    section: 8,
    sectionName: "Personal Leadership & Risk",
    sectionPosition: 5,
    totalInSection: 8,
    type: 'question',
    title: 'Where are you most stretched as a leader?',
    placeholder: 'Type your answer....',
    field: 'leadershipStretched',
    required: true,
    rows: 6
  },
  {
    id: 59,
    section: 8,
    sectionName: "Personal Leadership & Risk",
    sectionPosition: 6,
    totalInSection: 8,
    type: 'question',
    title: 'If you had to take a 90-day sabbatical, what would collapse?',
    placeholder: 'Type your answer....',
    field: 'sabbaticalRisks',
    required: true,
    rows: 6
  },
  {
    id: 60,
    section: 8,
    sectionName: "Personal Leadership & Risk",
    sectionPosition: 7,
    totalInSection: 8,
    type: 'question',
    title: 'What legacy are you trying to build through this company?',
    placeholder: 'Type your answer....',
    field: 'companyLegacy',
    required: true,
    rows: 6
  },
  {
    id: 61,
    section: 8,
    sectionName: "Personal Leadership & Risk",
    sectionPosition: 8,
    totalInSection: 8,
    type: 'question',
    title: 'What would need to happen in the next 12 months for this year to be a success?',
    placeholder: 'Type your answer....',
    field: 'yearSuccess',
    required: true,
    rows: 6
  }
];

export const getStepById = (id: number): OnboardingStep | undefined => {
  return onboardingSteps.find(step => step.id === id);
};

export const getStepsInSection = (section: number): OnboardingStep[] => {
  return onboardingSteps.filter(step => step.section === section);
};

export const getTotalSections = (): number => {
  return Math.max(...onboardingSteps.map(step => step.section));
};

export const getTotalSteps = (): number => {
  return onboardingSteps.length;
};