package domain

import (
	"time"

	"github.com/google/uuid"
)

// Tenant represents a tenant (agency) in the system
type Tenant struct {
	ID          uuid.UUID `json:"id" db:"id"`
	Name        string    `json:"name" db:"name"`
	Domain      string    `json:"domain" db:"domain"`
	Subdomain   string    `json:"subdomain" db:"subdomain"`
	CNPJ        string    `json:"cnpj,omitempty" db:"cnpj"`
	RazaoSocial string    `json:"razao_social,omitempty" db:"razao_social"`
	Email       string    `json:"email,omitempty" db:"email"`
	Phone       string    `json:"phone,omitempty" db:"phone"`
	Website     string    `json:"website,omitempty" db:"website"`
	Address     string    `json:"address,omitempty" db:"address"`
	Neighborhood string   `json:"neighborhood,omitempty" db:"neighborhood"`
	Number       string   `json:"number,omitempty" db:"number"`
	Complement   string   `json:"complement,omitempty" db:"complement"`
	City        string    `json:"city,omitempty" db:"city"`
	State       string    `json:"state,omitempty" db:"state"`
	Zip         string    `json:"zip,omitempty" db:"zip"`
	Description        string    `json:"description,omitempty" db:"description"`
	Industry           string    `json:"industry,omitempty" db:"industry"`
	TeamSize           string    `json:"team_size,omitempty" db:"team_size"`
	PrimaryColor       string    `json:"primary_color,omitempty" db:"primary_color"`
	SecondaryColor     string    `json:"secondary_color,omitempty" db:"secondary_color"`
	LogoURL            string    `json:"logo_url,omitempty" db:"logo_url"`
	LogoHorizontalURL  string    `json:"logo_horizontal_url,omitempty" db:"logo_horizontal_url"`
	IsActive           bool      `json:"is_active" db:"is_active"`
	CreatedAt          time.Time `json:"created_at" db:"created_at"`
	UpdatedAt          time.Time `json:"updated_at" db:"updated_at"`
}

// CreateTenantRequest represents the request to create a new tenant
type CreateTenantRequest struct {
	Name      string `json:"name"`
	Domain    string `json:"domain"`
	Subdomain string `json:"subdomain"`
}

// AgencyDetails aggregates tenant info with its admin user for superadmin view
type AgencyDetails struct {
	Tenant       *Tenant                 `json:"tenant"`
	Admin        *User                   `json:"admin,omitempty"`
	Subscription *AgencySubscriptionInfo `json:"subscription,omitempty"`
	AccessURL    string                  `json:"access_url"`
}

type AgencySubscriptionInfo struct {
	PlanID    string     `json:"plan_id"`
	PlanName  string     `json:"plan_name"`
	Status    string     `json:"status"`
	Solutions []Solution `json:"solutions"`
}
