"""
Referral schemas (3C.2).
"""

from __future__ import annotations

from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field


class ReferralKpiWindow(BaseModel):
    days: int = Field(ge=1, le=365)
    start: datetime
    end: datetime


class ReferralReferrerRow(BaseModel):
    user_id: int
    email: str
    invite_code: Optional[str] = None
    created_at: datetime
    referred_users_total: int = 0
    referred_users_window: int = 0
    referral_link_views_window: int = 0


class ReferralKpisResponse(BaseModel):
    window: ReferralKpiWindow
    totals: dict[str, int]
    referrers: list[ReferralReferrerRow]

