import { create } from 'zustand'
import type { DrawMode } from '@/types'

export type LineType = 'solid' | 'dashed' | 'dotted'

interface ToolStore {
  activeTool: DrawMode | null
  activeColor: string
  lineType: LineType
  lineWidth: number
  selectedFeatureId: string | null
  
  // Actions
  setActiveTool: (tool: ToolStore['activeTool']) => void
  setActiveColor: (color: string) => void
  setLineType: (type: ToolStore['lineType']) => void
  setLineWidth: (width: number) => void
  selectFeature: (id: string | null) => void
  resetTool: () => void
}

export const useToolStore = create<ToolStore>((set) => ({
  activeTool: 'select',
  activeColor: '#000000', // Default Schwarz
  lineType: 'solid',
  lineWidth: 3,
  selectedFeatureId: null,

  setActiveTool: (tool) => set({ activeTool: tool }),
  setActiveColor: (color) => set({ activeColor: color }),
  setLineType: (type) => set({ lineType: type }),
  setLineWidth: (width) => set({ lineWidth: width }),
  selectFeature: (id) => set({ selectedFeatureId: id }),
  
  resetTool: () => set({ 
    activeTool: 'select', 
    selectedFeatureId: null 
  }),
}))
