import { createContext, useContext } from 'react';

const localUser = { id: 'local-owner', email: 'local@shire3d', role: 'owner', local: true };
const AuthContext = createContext(null);

export function AuthProvider({ children }) {
  const value = {
    user: localUser, isAuthenticated: true, isLoadingAuth: false,
    isLoadingPublicSettings: false, authError: null,
    appPublicSettings: { mode: 'local' }, authChecked: true,
    logout: () => {}, navigateToLogin: () => {},
    checkUserAuth: async () => localUser,
    checkAppState: async () => ({ mode: 'local' }),
  };
  return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
}

export function useAuth() {
  const context = useContext(AuthContext);
  if (!context) throw new Error('useAuth must be used within an AuthProvider');
  return context;
}
