"""CFO (Management) schemas."""

from __future__ import annotations

from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field


class CfoMonthlyBucket(BaseModel):
    month: str  # YYYY-MM
    total_cost_usd: float = 0.0
    domains: int = 0


class CfoUpcomingCostRow(BaseModel):
    domain_id: int
    domain: str
    renewal_date: Optional[datetime] = None
    renewal_cost_usd: Optional[float] = None
    cost_source: str = Field(default="unknown", description="portfolio|tld_prices|unknown")
    is_sold: bool = False


class CfoKillListRow(BaseModel):
    domain_id: int
    domain: str
    renewal_date: Optional[datetime] = None
    renewal_cost_usd: Optional[float] = None
    cost_source: str = "unknown"
    auto_renew: bool = True
    is_dns_verified: bool = False
    yield_net_60d: float = 0.0
    yield_clicks_60d: int = 0
    reason: str


class CfoSummaryResponse(BaseModel):
    computed_at: datetime
    upcoming_30d_total_usd: float = 0.0
    upcoming_30d_rows: list[CfoUpcomingCostRow] = []
    monthly: list[CfoMonthlyBucket] = []
    kill_list: list[CfoKillListRow] = []


class SetToDropResponse(BaseModel):
    domain_id: int
    auto_renew: bool
    updated_at: datetime

