import type { DefaultSession } from 'next-auth';

declare module 'next-auth' {
  interface Session {
    user: DefaultSession['user'] & {
      id: string;
      systemRole: 'super_admin' | 'user';
      activeOrganizationId: string | null;
      activeOrganizationName: string | null;
      activeOrganizationPlan: string | null;
      activeMembershipRole: string | null;
      activeBusinessRole: string | null;
      activePermissions: string[];
      organizations: Array<{
        id: string;
        name: string;
        slug: string;
        role: string;
        businessRole: string;
        plan: string;
        imageUrl: string | null;
      }>;
    };
  }

  interface User {
    id: string;
    systemRole?: 'super_admin' | 'user';
    activeOrganizationId?: string | null;
  }
}

declare module 'next-auth/jwt' {
  interface JWT {
    sub?: string;
    systemRole?: 'super_admin' | 'user';
    activeOrganizationId?: string | null;
    activeOrganizationName?: string | null;
    activeOrganizationPlan?: string | null;
    activeMembershipRole?: string | null;
    activeBusinessRole?: string | null;
    activePermissions?: string[];
    organizations?: Array<{
      id: string;
      name: string;
      slug: string;
      role: string;
      businessRole: string;
      plan: string;
      imageUrl: string | null;
    }>;
  }
}
