from __future__ import annotations

from pydantic import BaseModel


class AllocationSlice(BaseModel):
    key: str
    label: str
    current_value_chf: str
    current_pct: str
    target_pct: str
    drift_pct: str
    status: str
    recommendation: str
    drilldown: list[str]


class AdvisorScorecard(BaseModel):
    key: str
    label: str
    status: str
    message: str


class AdvisorWorkflowStep(BaseModel):
    key: str
    label: str
    description: str
    execution_allowed: bool = False


class DrilldownNode(BaseModel):
    parent_key: str
    key: str
    label: str
    current_pct: str
    target_pct: str | None = None
    status: str
    note: str


class LookthroughPlaceholder(BaseModel):
    source_key: str
    label: str
    instrument_type: str
    status: str
    dimensions: list[str]
    next_step: str


class ImportSourceStatus(BaseModel):
    source_key: str
    label: str
    expected_files: list[str]
    mapped_to: list[str]
    status: str
    next_step: str


class InvestmentSignal(BaseModel):
    signal_id: str
    asset_key: str
    name: str
    symbol: str = ""
    asset_type: str
    portfolio_bucket: str
    market_value_chf: str | None = None
    portfolio_share_pct: str | None = None
    signal: str
    confidence: int
    horizon: str
    reason_summary: str
    positive_factors: list[str] = []
    risk_factors: list[str] = []
    data_quality: str = "unknown"
    source: str = "local_rules_v1"
    execution_allowed: bool = False


class PortfolioAdvisorSnapshot(BaseModel):
    title: str
    base_currency: str = "CHF"
    total_value_chf: str
    source_allocation: list[AllocationSlice]
    asset_allocation: list[AllocationSlice]
    drilldown_nodes: list[DrilldownNode]
    lookthrough_placeholders: list[LookthroughPlaceholder]
    investment_signals: list[InvestmentSignal] = []
    import_sources: list[ImportSourceStatus]
    scorecards: list[AdvisorScorecard]
    workflow: list[AdvisorWorkflowStep]
    tabs: list[str]
    guardrails: list[str]
    data_quality_status: str
    last_price_update: str | None = None
