// ENHANCED PROJECT STORE - Now includes Architecture Design state
import { create } from 'zustand';

const useProjectStore = create((set, get) => ({
  // Existing state
  currentStep: 'features',
  projectData: {},
  finalProjectData: {},
  techStackRecommendations: null,

  // MISSING: Properties for FeatureCardBoard
  selectedFeatures: [],
  availableSuggestions: [],
  
  // NEW: Architecture Design state
  architectureDesign: null,
  isGeneratingArchitecture: false,
  architectureError: null,

  // Existing actions
  setCurrentStep: (step) => set({ currentStep: step }),
  setProjectData: (data) => set({ projectData: data }),
  setFinalProjectData: (data) => set({ finalProjectData: data }),
  setTechStackRecommendations: (recommendations) => set({ 
    techStackRecommendations: recommendations 
  }),

  // NEW: Architecture Design actions
  setArchitectureDesign: (design) => set({ 
    architectureDesign: design,
    architectureError: null 
  }),
  
  setGeneratingArchitecture: (isGenerating) => set({ 
    isGeneratingArchitecture: isGenerating 
  }),
  
  setArchitectureError: (error) => set({ 
    architectureError: error,
    isGeneratingArchitecture: false 
  }),
  
  clearArchitectureDesign: () => set({ 
    architectureDesign: null,
    architectureError: null,
    isGeneratingArchitecture: false 
  }),

  // Enhanced navigation with architecture step
  goToNextStep: () => {
    const current = get().currentStep;
    const steps = ['features', 'business-questions', 'tech-stack', 'architecture', 'code-generation'];
    const currentIndex = steps.indexOf(current);
    if (currentIndex < steps.length - 1) {
      set({ currentStep: steps[currentIndex + 1] });
    }
  },

  goToPreviousStep: () => {
    const current = get().currentStep;
    const steps = ['features', 'business-questions', 'tech-stack', 'architecture', 'code-generation'];
    const currentIndex = steps.indexOf(current);
    if (currentIndex > 0) {
      set({ currentStep: steps[currentIndex - 1] });
    }
  },

  // Complete project flow data
  getCompleteProjectData: () => {
    const state = get();
    return {
      projectData: state.projectData,
      finalProjectData: state.finalProjectData,
      techStackRecommendations: state.techStackRecommendations,
      architectureDesign: state.architectureDesign,
      currentStep: state.currentStep
    };
  }
}));

export default useProjectStore;
