from pydantic import BaseModel, ConfigDict, Field
from typing import Optional, Dict, Any, List
from uuid import UUID
from datetime import datetime

# --- KATALÓGUS SÉMÁK (Gyári adatok) ---
class AssetCatalogBase(BaseModel):
    make: str
    model: str
    generation: Optional[str] = None
    year_from: Optional[int] = None
    year_to: Optional[int] = None
    vehicle_class: Optional[str] = None
    fuel_type: Optional[str] = None
    engine_code: Optional[str] = None

class AssetCatalogResponse(AssetCatalogBase):
    id: int
    factory_data: Optional[Dict[str, Any]] = None # A robot által gyűjtött adatok
    
    model_config = ConfigDict(from_attributes=True)

# --- JÁRMŰ SÉMÁK (Asset) ---
class AssetBase(BaseModel):
    vin: str = Field(..., min_length=17, max_length=17)
    license_plate: str
    name: Optional[str] = None
    year_of_manufacture: Optional[int] = None

class AssetCreate(AssetBase):
    # A létrehozáshoz kellenek a katalógus infók is
    make: str
    model: str
    vehicle_class: Optional[str] = "land"
    fuel_type: Optional[str] = None
    current_reading: Optional[int] = 0

class AssetResponse(AssetBase):
    id: UUID
    catalog_id: int
    is_verified: bool
    status: str
    
    model_config = ConfigDict(from_attributes=True)

# --- DIGITÁLIS IKER (Full Profile) ---
# Ez a séma felel a 9 pontos költség és a mélységi szerviz adatok átadásáért
class AssetFullProfile(BaseModel):
    identity: Dict[str, Any]
    telemetry: Dict[str, Any]
    financial_summary: Dict[str, Any]
    service_history: List[Dict[str, Any]]

    model_config = ConfigDict(from_attributes=True)