import { create } from 'zustand';

/**
 * UI 상태 관리 스토어
 */
export const useUIStore = create((set) => ({
  // 사이드패널 열림 상태
  isPanelOpen: true,
  togglePanel: () => set((state) => ({ isPanelOpen: !state.isPanelOpen })),
  setPanel: (isOpen) => set({ isPanelOpen: isOpen }),

  // 활성 메뉴
  activeMenu: 'ship',
  setActiveMenu: (menu) => set({ activeMenu: menu }),

  // 로딩 상태
  isLoading: false,
  setLoading: (loading) => set({ isLoading: loading }),

  // 모달 상태
  modals: {},
  openModal: (modalId, data = null) => set((state) => ({
    modals: { ...state.modals, [modalId]: { isOpen: true, data } },
  })),
  closeModal: (modalId) => set((state) => ({
    modals: { ...state.modals, [modalId]: { isOpen: false, data: null } },
  })),
}));
