import { create } from 'zustand';

export type SettingsTabType = 'general' | 'keys' | 'models' | 'styles' | 'sessions';

interface UIState {
  sidebarOpen: boolean;
  theme: 'light' | 'dark';
  isSettingsOpen: boolean;
  settingsActiveTab: SettingsTabType;
  toggleSidebar: () => void;
  setTheme: (theme: 'light' | 'dark') => void;
  openSettings: (tab?: SettingsTabType) => void;
  closeSettings: () => void;
  setSettingsActiveTab: (tab: SettingsTabType) => void;
}

export const useUIStore = create<UIState>((set) => ({
  sidebarOpen: true,
  theme: 'light',
  isSettingsOpen: false,
  settingsActiveTab: 'general',
  toggleSidebar: () => set((s) => ({ sidebarOpen: !s.sidebarOpen })),
  setTheme: (theme) => set({ theme }),
  openSettings: (tab) => set({ isSettingsOpen: true, settingsActiveTab: tab || 'general' }),
  closeSettings: () => set({ isSettingsOpen: false }),
  setSettingsActiveTab: (tab) => set({ settingsActiveTab: tab }),
}));
