package company

// CreateCompanyForm represents the form for creating a new company
type CreateCompanyForm struct {
	Name               string  `json:"name" valid:"required,length(2|200)"`
	Type               string  `json:"type" valid:"required,in(private|public|government|ngo|startup)"`
	RegistrationNumber string  `json:"registration_number" valid:"required,length(5|50)"`
	TaxID              string  `json:"tax_id" valid:"required,length(5|50)"`
	Industry           string  `json:"industry" valid:"required,length(2|100)"`
	Description        *string `json:"description,omitempty" valid:"optional,length(10|1000)"`
	Website            *string `json:"website,omitempty" valid:"optional,url"`

	// Business information
	EmployeeCount *int     `json:"employee_count,omitempty" valid:"optional,range(1|100000)"`
	AnnualRevenue *float64 `json:"annual_revenue,omitempty" valid:"optional,range(0|999999999999)"`
	FoundedYear   *int     `json:"founded_year,omitempty" valid:"optional,range(1800|2100)"`

	// Address information
	Address *AddressForm `json:"address,omitempty"`

	// Contact information
	ContactPerson *ContactPersonForm `json:"contact_person,omitempty"`
	Phone         *string            `json:"phone,omitempty" valid:"optional,length(10|20)"`
	Email         *string            `json:"email,omitempty" valid:"optional,email"`

	// Tags for categorization and search
	Tags *CompanyTagsForm `json:"tags,omitempty"`

	// Settings
	Language *string `json:"language,omitempty" valid:"optional,in(en|ar|fr|es|de|zh|ja|ko)"`
	Currency *string `json:"currency,omitempty" valid:"optional,in(USD|EUR|GBP|JPY|CAD|AUD|CHF|CNY|INR|BRL)"`
	Timezone *string `json:"timezone,omitempty" valid:"optional,length(3|50)"`
}

// UpdateCompanyForm represents the form for updating a company
type UpdateCompanyForm struct {
	Name               *string `json:"name,omitempty" valid:"optional,length(2|200)"`
	Type               *string `json:"type,omitempty" valid:"optional,in(private|public|government|ngo|startup)"`
	RegistrationNumber *string `json:"registration_number,omitempty" valid:"optional,length(5|50)"`
	TaxID              *string `json:"tax_id,omitempty" valid:"optional,length(5|50)"`
	Industry           *string `json:"industry,omitempty" valid:"optional,length(2|100)"`
	Description        *string `json:"description,omitempty" valid:"optional,length(10|1000)"`
	Website            *string `json:"website,omitempty" valid:"optional,url"`

	// Business information
	EmployeeCount *int     `json:"employee_count,omitempty" valid:"optional,range(1|100000)"`
	AnnualRevenue *float64 `json:"annual_revenue,omitempty" valid:"optional,range(0|999999999999)"`
	FoundedYear   *int     `json:"founded_year,omitempty" valid:"optional,range(1800|2100)"`

	// Address information
	Address *AddressForm `json:"address,omitempty"`

	// Contact information
	ContactPerson *ContactPersonForm `json:"contact_person,omitempty"`
	Phone         *string            `json:"phone,omitempty" valid:"optional,length(10|20)"`
	Email         *string            `json:"email,omitempty" valid:"optional,email"`

	// Tags for categorization and search
	Tags *CompanyTagsForm `json:"tags,omitempty"`

	// Settings
	Language *string `json:"language,omitempty" valid:"optional,in(en|ar|fr|es|de|zh|ja|ko)"`
	Currency *string `json:"currency,omitempty" valid:"optional,in(USD|EUR|GBP|JPY|CAD|AUD|CHF|CNY|INR|BRL)"`
	Timezone *string `json:"timezone,omitempty" valid:"optional,length(3|50)"`
}

// ListCompaniesForm represents the form for listing companies with filters
type ListCompaniesForm struct {
	Search           *string  `query:"search" valid:"optional"`
	Type             *string  `query:"type" valid:"optional,in(private|public|government|ngo|startup)"`
	Status           *string  `query:"status" valid:"optional,in(active|inactive|suspended|pending)"`
	Industry         *string  `query:"industry" valid:"optional"`
	IsVerified       *bool    `query:"is_verified" valid:"optional"`
	IsCompliant      *bool    `query:"is_compliant" valid:"optional"`
	Language         *string  `query:"language" valid:"optional"`
	Currency         *string  `query:"currency" valid:"optional"`
	CPVCodes         []string `query:"cpv_codes" valid:"optional"`
	Categories       []string `query:"categories" valid:"optional"`
	Keywords         []string `query:"keywords" valid:"optional"`
	Specializations  []string `query:"specializations" valid:"optional"`
	EmployeeCountMin *int     `query:"employee_count_min" valid:"optional,min(1)"`
	EmployeeCountMax *int     `query:"employee_count_max" valid:"optional,min(1)"`
	AnnualRevenueMin *float64 `query:"annual_revenue_min" valid:"optional,min(0)"`
	AnnualRevenueMax *float64 `query:"annual_revenue_max" valid:"optional,min(0)"`
	FoundedYearMin   *int     `query:"founded_year_min" valid:"optional,range(1800|2100)"`
	FoundedYearMax   *int     `query:"founded_year_max" valid:"optional,range(1800|2100)"`
	Limit            *int     `query:"limit" valid:"optional,range(1|100)"`
	Offset           *int     `query:"offset" valid:"optional,min(0)"`
	SortBy           *string  `query:"sort_by" valid:"optional,in(name|type|industry|created_at|updated_at|status|employee_count|annual_revenue)"`
	SortOrder        *string  `query:"sort_order" valid:"optional,in(asc|desc)"`
}

// UpdateCompanyStatusForm represents the form for updating company status
type UpdateCompanyStatusForm struct {
	Status string `json:"status" valid:"required,in(active|inactive|suspended|pending)"`
}

// UpdateCompanyVerificationForm represents the form for updating company verification status
type UpdateCompanyVerificationForm struct {
	IsVerified      bool    `json:"is_verified"`
	IsCompliant     bool    `json:"is_compliant"`
	ComplianceNotes *string `json:"compliance_notes,omitempty" valid:"optional,length(0|1000)"`
}

// UpdateCompanyTagsForm represents the form for updating company tags
type UpdateCompanyTagsForm struct {
	Tags *CompanyTagsForm `json:"tags" valid:"required"`
}

// AddTagsForm represents the form for adding tags to a company
type AddTagsForm struct {
	CPVCodes        []string `json:"cpv_codes,omitempty" valid:"optional"`
	Categories      []string `json:"categories,omitempty" valid:"optional"`
	Keywords        []string `json:"keywords,omitempty" valid:"optional"`
	Specializations []string `json:"specializations,omitempty" valid:"optional"`
	Certifications  []string `json:"certifications,omitempty" valid:"optional"`
}

// RemoveTagsForm represents the form for removing tags from a company
type RemoveTagsForm struct {
	CPVCodes        []string `json:"cpv_codes,omitempty" valid:"optional"`
	Categories      []string `json:"categories,omitempty" valid:"optional"`
	Keywords        []string `json:"keywords,omitempty" valid:"optional"`
	Specializations []string `json:"specializations,omitempty" valid:"optional"`
	Certifications  []string `json:"certifications,omitempty" valid:"optional"`
}

// SuspendCompanyForm represents the form for suspending a company
type SuspendCompanyForm struct {
	Reason string `json:"reason" valid:"required,length(10|500)"`
}

// AddressForm represents the form for company address
type AddressForm struct {
	Street     string `json:"street" valid:"required,length(5|200)"`
	City       string `json:"city" valid:"required,length(2|100)"`
	State      string `json:"state" valid:"required,length(2|100)"`
	PostalCode string `json:"postal_code" valid:"required,length(3|20)"`
	Country    string `json:"country" valid:"required,length(2|100)"`
}

// ContactPersonForm represents the form for contact person
type ContactPersonForm struct {
	FirstName string  `json:"first_name" valid:"required,length(2|50)"`
	LastName  string  `json:"last_name" valid:"required,length(2|50)"`
	FullName  string  `json:"full_name" valid:"required,length(2|100)"`
	Position  string  `json:"position" valid:"required,length(2|100)"`
	Email     string  `json:"email" valid:"required,email"`
	Phone     string  `json:"phone" valid:"required,length(10|20)"`
	Mobile    *string `json:"mobile,omitempty" valid:"optional,length(10|20)"`
	IsPrimary bool    `json:"is_primary"`
}

// CompanyTagsForm represents the form for company tags
type CompanyTagsForm struct {
	CPVCodes        []string `json:"cpv_codes,omitempty" valid:"optional"`
	Categories      []string `json:"categories,omitempty" valid:"optional"`
	Keywords        []string `json:"keywords,omitempty" valid:"optional"`
	Specializations []string `json:"specializations,omitempty" valid:"optional"`
	Certifications  []string `json:"certifications,omitempty" valid:"optional"`
}

// CompanyListResponse represents the response for listing companies
type CompanyListResponse struct {
	Companies  []*CompanyResponse `json:"companies"`
	Total      int64              `json:"total"`
	Limit      int                `json:"limit"`
	Offset     int                `json:"offset"`
	TotalPages int                `json:"total_pages"`
}

// Company search and matching DTOs
type CompanySearchForm struct {
	Query           *string  `query:"q" valid:"optional"`
	CPVCodes        []string `query:"cpv_codes" valid:"optional"`
	Categories      []string `query:"categories" valid:"optional"`
	Keywords        []string `query:"keywords" valid:"optional"`
	Specializations []string `query:"specializations" valid:"optional"`
	Industry        *string  `query:"industry" valid:"optional"`
	Location        *string  `query:"location" valid:"optional"`
	MinEmployees    *int     `query:"min_employees" valid:"optional,min(1)"`
	MaxEmployees    *int     `query:"max_employees" valid:"optional,min(1)"`
	MinRevenue      *float64 `query:"min_revenue" valid:"optional,min(0)"`
	MaxRevenue      *float64 `query:"max_revenue" valid:"optional,min(0)"`
	IsVerified      *bool    `query:"is_verified" valid:"optional"`
	IsCompliant     *bool    `query:"is_compliant" valid:"optional"`
	Limit           *int     `query:"limit" valid:"optional,range(1|100)"`
	Offset          *int     `query:"offset" valid:"optional,min(0)"`
}

// Company statistics DTOs
type CompanyStatsResponse struct {
	TotalCompanies      int64            `json:"total_companies"`
	ActiveCompanies     int64            `json:"active_companies"`
	VerifiedCompanies   int64            `json:"verified_companies"`
	CompaniesByType     map[string]int64 `json:"companies_by_type"`
	CompaniesByIndustry map[string]int64 `json:"companies_by_industry"`
	CompaniesByStatus   map[string]int64 `json:"companies_by_status"`
	TopCategories       []CategoryCount  `json:"top_categories"`
	TopCPVCodes         []CPVCodeCount   `json:"top_cpv_codes"`
}

type CategoryCount struct {
	Category string `json:"category"`
	Count    int64  `json:"count"`
}

type CPVCodeCount struct {
	CPVCode string `json:"cpv_code"`
	Count   int64  `json:"count"`
}
