"""
Shared UI type definitions.

These types are used across multiple components and mirror TypeScript
interfaces from lightwave-ui/src/types/ and common component props.

Example:
    from lightwave.schema.pydantic.ui.types import CTAProps, BadgeProps

    cta = CTAProps(label="Get Started", href="/signup")
    badge = BadgeProps(text="New", color="brand")
"""

from typing import Literal

from pydantic import BaseModel, ConfigDict, Field


class CTAProps(BaseModel):
    """
    Call-to-action button props.

    Matches TypeScript:
        interface CTAProps {
            label: string;
            href: string;
            icon?: string;
            color?: "primary" | "secondary" | "tertiary" | "link-gray" | "link-color";
            size?: "sm" | "md" | "lg" | "xl";
        }
    """

    label: str = Field(..., description="Button text")
    href: str = Field(..., description="Link destination")
    icon: str | None = Field(None, description="Icon name")
    color: Literal["primary", "secondary", "tertiary", "link-gray", "link-color"] = Field(
        "primary", description="Button color variant"
    )
    size: Literal["sm", "md", "lg", "xl"] = Field("lg", description="Button size")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class BadgeProps(BaseModel):
    """
    Badge/tag props.

    Matches TypeScript:
        interface BadgeProps {
            text: string;
            color?: BadgeColor;
            href?: string;
        }
    """

    text: str = Field(..., description="Badge text")
    color: Literal[
        "gray",
        "brand",
        "error",
        "warning",
        "success",
        "gray-blue",
        "blue-light",
        "blue",
        "indigo",
        "purple",
        "pink",
        "orange",
    ] = Field("brand", description="Badge color variant")
    href: str | None = Field(None, description="Optional link")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class PersonInfo(BaseModel):
    """
    Author/person information used in testimonials, team sections, etc.

    Matches TypeScript:
        interface PersonInfo {
            name: string;
            title?: string;
            avatar?: string;
            verified?: boolean;
        }
    """

    name: str = Field(..., description="Person's full name")
    title: str | None = Field(None, description="Job title or role")
    avatar: str | None = Field(None, description="Avatar image URL")
    verified: bool = Field(False, description="Whether person is verified")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class CompanyInfo(BaseModel):
    """
    Company logo/info used in social proof, testimonials, etc.

    Matches TypeScript:
        interface CompanyInfo {
            name: string;
            logoLight: string;
            logoDark: string;
        }
    """

    name: str = Field(..., description="Company name")
    logo_light: str = Field(..., serialization_alias="logoLight", description="Logo URL for light mode")
    logo_dark: str = Field(..., serialization_alias="logoDark", description="Logo URL for dark mode")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class ImagePair(BaseModel):
    """
    Light/dark mode image pair.

    Matches TypeScript:
        interface ImagePair {
            light: string;
            dark: string;
        }
    """

    light: str = Field(..., description="Image URL for light mode")
    dark: str = Field(..., description="Image URL for dark mode")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# Navigation Types
# =============================================================================


class NavItem(BaseModel):
    """
    Navigation item for headers/footers.

    Matches TypeScript:
        interface NavItem {
            label: string;
            href?: string;
            children?: NavItem[];
        }
    """

    label: str = Field(..., description="Display text")
    href: str | None = Field(None, description="Link destination")
    children: list["NavItem"] | None = Field(None, description="Nested nav items")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class FooterNavItem(BaseModel):
    """
    Footer navigation item.

    Matches TypeScript:
        interface FooterNavItem {
            label: string;
            href: string;
        }
    """

    label: str = Field(..., description="Display text")
    href: str = Field(..., description="Link destination")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# Auth Types
# =============================================================================


class AuthUser(BaseModel):
    """
    Authenticated user info for header display.

    Matches TypeScript:
        interface AuthUser {
            name: string;
            email: string;
            avatarUrl?: string;
        }
    """

    name: str = Field(..., description="User's display name")
    email: str = Field(..., description="User's email")
    avatar_url: str | None = Field(None, serialization_alias="avatarUrl", description="Avatar image URL")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class AuthState(BaseModel):
    """
    Authentication state for header components.

    Matches TypeScript:
        interface AuthState {
            isAuthenticated: boolean;
            user?: AuthUser;
        }
    """

    is_authenticated: bool = Field(..., serialization_alias="isAuthenticated", description="Whether user is logged in")
    user: AuthUser | None = Field(None, description="User info if authenticated")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class AuthConfig(BaseModel):
    """
    Authentication configuration for header.

    Matches TypeScript:
        interface AuthConfig {
            showSignup?: boolean;
            showLogin?: boolean;
            loginUrl?: string;
            signupUrl?: string;
            profileUrl?: string;
            settingsUrl?: string;
            logoutUrl?: string;
            dashboardUrl?: string;
        }
    """

    show_signup: bool | None = Field(True, serialization_alias="showSignup", description="Show signup button")
    show_login: bool | None = Field(True, serialization_alias="showLogin", description="Show login button")
    login_url: str | None = Field("/login", serialization_alias="loginUrl", description="Login page URL")
    signup_url: str | None = Field("/signup", serialization_alias="signupUrl", description="Signup page URL")
    profile_url: str | None = Field("/profile", serialization_alias="profileUrl", description="Profile page URL")
    settings_url: str | None = Field("/settings", serialization_alias="settingsUrl", description="Settings page URL")
    logout_url: str | None = Field("/logout", serialization_alias="logoutUrl", description="Logout URL")
    dashboard_url: str | None = Field(
        "/dashboard",
        serialization_alias="dashboardUrl",
        description="Dashboard URL",
    )

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# Feature Types
# =============================================================================


class FeatureItem(BaseModel):
    """
    Feature item for feature sections.

    Matches TypeScript:
        interface FeatureItem {
            title: string;
            description: string;
            icon?: string;
            href?: string;
        }
    """

    title: str = Field(..., description="Feature title")
    description: str = Field(..., description="Feature description")
    icon: str | None = Field(None, description="Icon name")
    href: str | None = Field(None, description="Optional link")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# Testimonial Types
# =============================================================================


class TestimonialItem(BaseModel):
    """
    Testimonial/review item.

    Matches TypeScript:
        interface TestimonialItem {
            id?: string;
            quote: string;
            author: string;
            cite?: string;
            imageUrl?: string;
            industry?: string;
            rating?: number;
        }
    """

    id: str | None = Field(None, description="Unique identifier")
    quote: str | None = Field(None, description="Testimonial quote")
    author: str = Field(..., description="Author name")
    cite: str | None = Field(None, description="Citation (job title, company)")
    image_url: str | None = Field(None, serialization_alias="imageUrl", description="Author photo URL")
    industry: str | None = Field(None, description="Industry/category")
    rating: int | None = Field(None, ge=1, le=5, description="Star rating 1-5")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# Pricing Types
# =============================================================================


class PricingFeature(BaseModel):
    """
    Feature item in a pricing tier.

    Matches TypeScript:
        interface PricingFeature {
            text: string;
            included: boolean;
        }
    """

    text: str = Field(..., description="Feature description")
    included: bool = Field(True, description="Whether feature is included")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class PricingTier(BaseModel):
    """
    Pricing tier/plan.

    Matches TypeScript:
        interface PricingTier {
            name: string;
            price: string;
            priceMonthly?: string;
            priceAnnual?: string;
            description?: string;
            features: PricingFeature[];
            cta: CTAProps;
            highlighted?: boolean;
            badge?: string;
        }
    """

    name: str = Field(..., description="Tier name")
    price: str = Field(..., description="Display price")
    price_monthly: str | None = Field(None, serialization_alias="priceMonthly", description="Monthly price")
    price_annual: str | None = Field(None, serialization_alias="priceAnnual", description="Annual price")
    description: str | None = Field(None, description="Tier description")
    features: list[PricingFeature] = Field(default_factory=list, description="List of features")
    cta: CTAProps | None = Field(None, description="CTA button")
    highlighted: bool = Field(False, description="Whether tier is highlighted/popular")
    badge: str | None = Field(None, description="Badge text (e.g., 'Most Popular')")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# FAQ Types
# =============================================================================


class FAQItem(BaseModel):
    """
    FAQ item.

    Matches TypeScript:
        interface FAQItem {
            question: string;
            answer: string;
        }
    """

    question: str = Field(..., description="Question text")
    answer: str = Field(..., description="Answer text")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# Blog Types
# =============================================================================


class ArticleProps(BaseModel):
    """
    Blog article props.

    Matches TypeScript:
        interface ArticleProps {
            id: string;
            title: string;
            summary: string;
            thumbnail: string;
            href: string;
            author: PersonInfo;
            category?: BadgeProps;
            publishedAt: string;
            readTime?: string;
        }
    """

    id: str = Field(..., description="Article ID")
    title: str = Field(..., description="Article title")
    summary: str = Field(..., description="Article summary/excerpt")
    thumbnail: str = Field(..., description="Thumbnail image URL")
    href: str = Field(..., description="Article URL")
    author: PersonInfo = Field(..., description="Author information")
    category: BadgeProps | None = Field(None, description="Category badge")
    published_at: str = Field(..., serialization_alias="publishedAt", description="Publication date")
    read_time: str | None = Field(None, serialization_alias="readTime", description="Estimated read time")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# Metric Types
# =============================================================================


class MetricItem(BaseModel):
    """
    Metric/stat item.

    Matches TypeScript:
        interface MetricItem {
            value: string;
            label: string;
            description?: string;
        }
    """

    value: str = Field(..., description="Metric value (e.g., '99%', '10M+')")
    label: str = Field(..., description="Metric label")
    description: str | None = Field(None, description="Additional description")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# =============================================================================
# Team Types
# =============================================================================


class TeamMember(BaseModel):
    """
    Team member info.

    Matches TypeScript:
        interface TeamMember {
            name: string;
            title: string;
            imageUrl: string;
            bio?: string;
            socials?: SocialLink[];
        }
    """

    name: str = Field(..., description="Member name")
    title: str = Field(..., description="Job title")
    image_url: str = Field(..., serialization_alias="imageUrl", description="Photo URL")
    bio: str | None = Field(None, description="Short bio")
    socials: list["SocialLink"] | None = Field(None, description="Social links")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class SocialLink(BaseModel):
    """
    Social media link.

    Matches TypeScript:
        interface SocialLink {
            platform: string;
            href: string;
        }
    """

    platform: Literal["twitter", "linkedin", "github", "instagram", "facebook", "youtube", "website"] = Field(
        ..., description="Platform name"
    )
    href: str = Field(..., description="Profile URL")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


# Allow forward references
NavItem.model_rebuild()
TeamMember.model_rebuild()

__all__ = [
    # Core types
    "CTAProps",
    "BadgeProps",
    "PersonInfo",
    "CompanyInfo",
    "ImagePair",
    # Navigation
    "NavItem",
    "FooterNavItem",
    # Auth
    "AuthUser",
    "AuthState",
    "AuthConfig",
    # Features
    "FeatureItem",
    # Testimonials
    "TestimonialItem",
    # Pricing
    "PricingFeature",
    "PricingTier",
    # FAQ
    "FAQItem",
    # Blog
    "ArticleProps",
    # Metrics
    "MetricItem",
    # Team
    "TeamMember",
    "SocialLink",
]
