from datetime import datetime

from pydantic import BaseModel

from .organization import OrgRole


class Membership(BaseModel):
    id: str | None = None
    user_id: str
    organization_id: str
    role_in_org: OrgRole
    team_ids: list[str] = []  # teams the user belongs to within this org (MT-17)
    created_at: datetime | None = None
    created_by: str | None = None


class MembershipCreate(BaseModel):
    user_id: str
    role_in_org: OrgRole = OrgRole.MEMBER


class MembershipUpdate(BaseModel):
    role_in_org: OrgRole


class MemberDetail(BaseModel):
    """Membership enriched with user info for list endpoints."""
    membership_id: str
    user_id: str
    email: str
    full_name: str
    role_in_org: OrgRole
    created_at: datetime | None = None
