from __future__ import annotations

from app.schemas.base import CamelModel


class PerformanceMetrics(CamelModel):
    monthly_hours: float
    monthly_salary: float
    customer_balance: float
    tasks_completed: int
    perf_current: float
    perf_target: float


class IncomeItem(CamelModel):
    label: str
    amount: str
    color: str


class IncomeSection(CamelModel):
    this_month: list[IncomeItem] = []
    last_month: list[IncomeItem] = []


class CoachTaskItem(CamelModel):
    type_label: str
    type_class: str
    customer_name: str
    customer_id: int | None = None
    note_count: int = 0
    pinned: bool = False
    notes: list[dict] | None = None


class AbandonedTask(CamelModel):
    customer_name: str
    reason: str


class TopCustomer(CamelModel):
    id: int
    name: str
    initial: str
    avatar_gradient: str
    heart_emoji: str    # ❤️ / 💛 / 🤍
    score: str
    score_color: str
    service_count: int
    balance: str
    consume: str


class CoachServiceRecord(CamelModel):
    customer_id: int | None = None
    customer_name: str
    initial: str
    avatar_gradient: str
    type: str
    type_class: str
    table: str | None = None
    duration: str
    income: str
    date: str
    perf_hours: str | None = None


class HistoryMonth(CamelModel):
    month: str
    estimated: bool
    customers: str
    hours: str
    salary: str
    callback_done: int
    recall_done: int


class CoachNoteItem(CamelModel):
    id: int
    content: str
    timestamp: str
    score: int | None = None
    customer_name: str
    tag_label: str
    created_at: str


class CoachDetailResponse(CamelModel):
    """COACH-1 响应。"""
    # 基础信息
    id: int
    name: str
    avatar: str
    level: str
    skills: list[str] = []
    work_years: float = 0
    customer_count: int = 0
    hire_date: str | None = None
    # 绩效
    performance: PerformanceMetrics
    # 收入
    income: IncomeSection
    # 档位
    tier_nodes: list[float] = []
    # 任务分组
    visible_tasks: list[CoachTaskItem] = []
    hidden_tasks: list[CoachTaskItem] = []
    abandoned_tasks: list[AbandonedTask] = []
    # TOP 客户
    top_customers: list[TopCustomer] = []
    # 近期服务记录
    service_records: list[CoachServiceRecord] = []
    # 历史月份
    history_months: list[HistoryMonth] = []
    # 备注
    notes: list[CoachNoteItem] = []
