"""Pydantic v2 data models for AI-driven Lead Generation & Tech Scoping."""
from __future__ import annotations
from pydantic import BaseModel, Field
from typing import List, Optional


class CompanyTechProfile(BaseModel):
    company_name: str = Field(
        ...,
        description="Official company name as detected from the page content",
        min_length=1,
    )
    detected_technologies: List[str] = Field(
        default_factory=list,
        description="Detected technologies: Spark, Kafka, AWS, Kubernetes, Snowflake, Airflow, dbt, etc.",
    )
    current_pain_points: List[str] = Field(
        default_factory=list,
        description="Inferred pain points: legacy migration, data quality, scalability, missing AI/ML, etc.",
    )
    estimated_data_maturity: Optional[str] = Field(
        default="Medium",
        description="Estimated data maturity level: Low, Medium, or High",
    )
    outreach_hook: Optional[str] = Field(
        default="",
        description="Concrete reason why a Forward Deployed Engineer can help this company right now",
    )
    industry: Optional[str] = Field(
        default=None,
        description="Detected industry or sector",
    )
    company_size_hint: Optional[str] = Field(
        default=None,
        description="Estimated company size: Startup, Scale-up, Mid-market, Enterprise",
    )
    tech_blog_posts: Optional[str] = Field(
        default=None,
        description="URL to engineering/tech blog if detected",
    )
    hiring_roles: List[str] = Field(
        default_factory=list,
        description="Job titles/roles detected from careers page: Data Engineer, ML Engineer, DevOps, etc.",
    )
    desired_skills: List[str] = Field(
        default_factory=list,
        description="Specific skills/technologies they are hiring for: Python, Spark, Terraform, dbt, etc.",
    )
    job_listings_url: Optional[str] = Field(
        default=None,
        description="URL to careers/jobs page if detected on the site",
    )
    extracted_at: Optional[str] = Field(
        default=None,
        description="ISO timestamp of extraction",
    )
    source_url: Optional[str] = Field(
        default=None,
        description="Original URL that was scraped",
    )


class ScrapeResult(BaseModel):
    url: str
    title: str
    text_content: str
    text_length: int
    status_code: Optional[int] = None
    error: Optional[str] = None


class LeadGenRequest(BaseModel):
    url: str = Field(..., description="URL of the target company page to analyze")
    force_refresh: bool = Field(default=False, description="Skip cache and force fresh scrape")


class LeadGenResponse(BaseModel):
    success: bool
    profile: Optional[CompanyTechProfile] = None
    error: Optional[str] = None
    elapsed_ms: Optional[float] = None
