"use client"

import { create } from "zustand"

interface MailUiState {
  sidebarCollapsed: boolean
  mobileSearchOpen: boolean
  folderUnreadCounts: Record<string, number>
}

interface MailUiActions {
  setSidebarCollapsed: (collapsed: boolean) => void
  toggleSidebarCollapsed: () => void
  setMobileSearchOpen: (open: boolean) => void
  setFolderUnreadCounts: (counts: Record<string, number>) => void
}

export const useMailUiStore = create<MailUiState & MailUiActions>()((set) => ({
  sidebarCollapsed: true,
  mobileSearchOpen: false,
  folderUnreadCounts: {},

  setSidebarCollapsed: (collapsed) => set({ sidebarCollapsed: collapsed }),
  toggleSidebarCollapsed: () =>
    set((s) => ({ sidebarCollapsed: !s.sidebarCollapsed })),
  setMobileSearchOpen: (open) => set({ mobileSearchOpen: open }),
  setFolderUnreadCounts: (counts) => set({ folderUnreadCounts: counts }),
}))
