import { DefaultSession, DefaultUser } from 'next-auth';
import { JWT } from 'next-auth/jwt';

declare module 'next-auth' {
  interface Session {
    user: {
      id: string;
      roles: string[];
      permissions: string[];
      department?: string;
      title?: string;
      avatar?: string;
    } & DefaultSession['user'];
  }

  interface User extends DefaultUser {
    id: string;
    roles: string[];
    permissions: string[];
    department?: string;
    title?: string;
    avatar?: string;
  }
}

declare module 'next-auth/jwt' {
  interface JWT {
    id: string;
    roles: string[];
    permissions: string[];
    department?: string;
    title?: string;
    avatar?: string;
  }
}

// Permission checking types
export interface PermissionCheck {
  resource: string;
  action: 'read' | 'write' | 'delete' | 'approve' | 'admin';
  scope?: 'all' | 'department' | 'team' | 'own';
}

export interface AuthenticatedUser {
  id: string;
  email: string;
  name?: string;
  roles: string[];
  permissions: string[];
  department?: string;
}
