import { create } from "zustand";

export const useAppStore = create((set) => ({
  // Selected symbol for detailed view
  selectedSymbol: null,
  setSelectedSymbol: (symbol) => set({ selectedSymbol: symbol }),

  // Active panel/tab
  activePanel: "flow", // flow, analysis, scanner, alerts
  setActivePanel: (panel) => set({ activePanel: panel }),

  // Filters
  filters: {
    symbol: null,
    type: null, // CALL or PUT
    minPremium: null,
    minScore: 60,
  },
  setFilters: (filters) =>
    set((state) => ({
      filters: { ...state.filters, ...filters },
    })),

  // WebSocket connection status
  wsConnected: false,
  setWsConnected: (connected) => set({ wsConnected: connected }),

  // Latest alerts
  alerts: [],
  addAlert: (alert) =>
    set((state) => ({
      alerts: [alert, ...state.alerts].slice(0, 50), // Keep last 50
    })),

  // Theme (for future dark mode support)
  theme: "light",
  setTheme: (theme) => set({ theme }),
}));

