import { create } from 'zustand'

export type SidebarTab = 'map' | 'journal'
export type ConnectionStatus = 'connected' | 'reconnecting' | 'offline'

interface UIStore {
  sidebarOpen: boolean
  sidebarTab: SidebarTab
  activeModal: string | null
  isEditing: boolean
  connectionStatus: ConnectionStatus
  
  // Actions
  toggleSidebar: () => void
  setSidebarOpen: (open: boolean) => void
  setSidebarTab: (tab: SidebarTab) => void
  openModal: (modal: string) => void
  closeModal: () => void
  setIsEditing: (editing: boolean) => void
  setConnectionStatus: (status: ConnectionStatus) => void
}

export const useUIStore = create<UIStore>((set) => ({
  sidebarOpen: true,
  sidebarTab: 'map',
  activeModal: null,
  isEditing: false,
  connectionStatus: 'offline',

  toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
  setSidebarOpen: (open) => set({ sidebarOpen: open }),
  setSidebarTab: (tab) => set({ sidebarTab: tab }),
  
  openModal: (modal) => set({ activeModal: modal }),
  closeModal: () => set({ activeModal: null }),
  
  setIsEditing: (editing) => set({ isEditing: editing }),
  setConnectionStatus: (status) => set({ connectionStatus: status }),
}))
