/**
 * Zustand Store — UI 状态管理
 *
 * 主题、设置弹窗、引导向导等全局 UI 状态。
 */

import { create } from 'zustand';

export type ThemeMode = 'dark' | 'light' | 'auto';

interface UIState {
  // 主题
  theme: ThemeMode;
  resolvedTheme: 'dark' | 'light';

  // 弹窗
  settingsOpen: boolean;
  onboardingCompleted: boolean;

  // Actions
  setTheme: (theme: ThemeMode) => void;
  setResolvedTheme: (theme: 'dark' | 'light') => void;
  openSettings: () => void;
  closeSettings: () => void;
  setOnboardingCompleted: (completed: boolean) => void;
}

export const useUIStore = create<UIState>((set) => ({
  theme: 'auto',
  resolvedTheme: 'dark',
  settingsOpen: false,
  onboardingCompleted: false,

  setTheme: (theme) => set({ theme }),
  setResolvedTheme: (resolvedTheme) => set({ resolvedTheme }),
  openSettings: () => set({ settingsOpen: true }),
  closeSettings: () => set({ settingsOpen: false }),
  setOnboardingCompleted: (completed) => set({ onboardingCompleted: completed }),
}));
