from __future__ import annotations

from typing import Any, Dict, List, Literal
from pydantic import Field
from .ir_bundle import StrictBase


class DesignSystem(StrictBase):
    theme_mode: Literal["light", "dark"] = "light"
    density: Literal["compact", "comfortable", "spacious"] = "comfortable"
    color_primary: str = "#1677ff"
    color_success: str = "#52c41a"
    color_warning: str = "#faad14"
    color_error: str = "#ff4d4f"
    color_bg_container: str = "#ffffff"
    color_bg_layout: str = "#f5f5f5"
    color_text: str = "#000000e0"
    color_border: str = "#d9d9d9"
    font_family: str = "Inter, -apple-system, BlinkMacSystemFont, sans-serif"
    font_size_base: int = 14
    border_radius: int = 6
    component_overrides: Dict[str, Any] = Field(default_factory=dict)


class PageNode(StrictBase):
    page_id: str
    page_title: str
    route_path: str
    route_params: List[str] = Field(default_factory=list)
    image_indices: List[int] = Field(default_factory=list)
    description: str = ""
    navigates_to: List[str] = Field(default_factory=list)


class SharedStateField(StrictBase):
    key: str
    type: str
    initial_value: str = "null"
    description: str = ""


class AppPlan(StrictBase):
    app_name: str
    pages: List[PageNode]
    shared_state: List[SharedStateField] = Field(default_factory=list)
    default_route: str
    design_system: DesignSystem = Field(default_factory=DesignSystem)
