import uuid
from datetime import datetime
from typing import Any, Dict, Optional

from pydantic import BaseModel, ConfigDict

from app.models.plant import RootDepthCategory, VarietyType


class PlantBase(BaseModel):
    name: str
    species: str
    variety_type: VarietyType
    drought_tolerance: int
    salinity_tolerance: int
    heat_tolerance: int
    cold_tolerance: int
    disease_resistance: Dict[str, Any] = {}
    optimal_ph_min: float
    optimal_ph_max: float
    nutrient_uptake_efficiency: Dict[str, Any] = {}
    root_depth_category: RootDepthCategory
    growth_cycle_days: int
    yield_potential_kg_per_plant: float
    description: Optional[str] = None
    image_url: Optional[str] = None


class PlantCreate(PlantBase):
    pass


class PlantResponse(PlantBase):
    id: uuid.UUID
    created_at: datetime
    updated_at: datetime

    model_config = ConfigDict(from_attributes=True)
