import { create } from 'zustand';

interface SessionState {
    activeSessionId: string | null;
    teacherStatus: 'idle' | 'thinking' | 'typing';
    isDraftViewOpen: boolean;
    actions: {
        setActiveSession: (id: string | null) => void;
        setTeacherStatus: (status: 'idle' | 'thinking' | 'typing') => void;
        setDraftViewOpen: (isOpen: boolean) => void;
    };
}

export const useSessionStore = create<SessionState>((set) => ({
    activeSessionId: null,
    teacherStatus: 'idle',
    isDraftViewOpen: false,
    actions: {
        setActiveSession: (id) => set({ activeSessionId: id }),
        setTeacherStatus: (status) => set({ teacherStatus: status }),
        setDraftViewOpen: (isOpen) => set({ isDraftViewOpen: isOpen })
    }
}));

// Atomic selector hooks
export const useActiveSessionId = () => useSessionStore((s) => s.activeSessionId);
export const useTeacherStatus = () => useSessionStore((s) => s.teacherStatus);
export const useIsDraftViewOpen = () => useSessionStore((s) => s.isDraftViewOpen);
export const useSessionActions = () => useSessionStore((s) => s.actions);
