{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "reversa-pricing-profile-v1.1",
  "title": "Reversa Pricing Profile",
  "description": "Perfil de cobrança gerado pelo agente reversa-pricing-profile, consumido pelos agentes reversa-pricing-size e reversa-pricing-estimate.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "created_at",
    "country",
    "currency",
    "seniority",
    "hourly_rate",
    "hourly_rate_mode",
    "margin_percent",
    "tax_regime",
    "tax_factor",
    "tax_factor_kind",
    "tax_factor_source",
    "includes_vat",
    "vat_pass_through_warning",
    "tax_regime_confidence",
    "pricing_models"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1.1",
      "description": "Versão do schema. v1 = 1.0."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp ISO 8601 UTC da criação ou da última regeneração do profile."
    },
    "country": {
      "type": "string",
      "pattern": "^[A-Z]{2}$",
      "description": "Código ISO 3166-1 alpha-2 do país de operação."
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$",
      "description": "Código ISO 4217 da moeda local."
    },
    "seniority": {
      "type": "string",
      "enum": ["junior", "mid", "senior", "staff_lead", "principal"]
    },
    "hourly_rate": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Taxa hora líquida na moeda local."
    },
    "hourly_rate_mode": {
      "type": "string",
      "enum": ["direto", "derivado"],
      "description": "direto = usuário informou o valor; derivado = calculado a partir de monthly_target_income e billable_hours_per_month."
    },
    "monthly_target_income": {
      "type": ["number", "null"],
      "exclusiveMinimum": 0,
      "description": "Renda mensal líquida desejada na moeda local. Obrigatório quando hourly_rate_mode = derivado, null caso contrário."
    },
    "billable_hours_per_month": {
      "type": ["number", "null"],
      "minimum": 1,
      "maximum": 720,
      "description": "Horas faturáveis estimadas por mês. Obrigatório quando hourly_rate_mode = derivado, null caso contrário."
    },
    "margin_percent": {
      "type": "number",
      "minimum": 0,
      "maximum": 200,
      "description": "Markup de projeto sobre custo direto, em percentual. O nome historico do campo permanece margin_percent por compatibilidade."
    },
    "tax_regime": {
      "type": "string",
      "minLength": 1,
      "description": "Chave canônica do regime tributário documentado em references/tax-regimes.md, ou 'outro'."
    },
    "tax_factor": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Fator de imposto aproximado associado ao regime. Aplicado pelo Pricer sobre o custo direto."
    },
    "tax_factor_kind": {
      "type": "string",
      "enum": ["effective_reserve_estimate", "statutory_proxy", "not_computed"],
      "description": "Tipo do fator: reserva efetiva aproximada, proxy legal simplificada ou imposto nao computado."
    },
    "tax_factor_source": {
      "type": "string",
      "minLength": 1,
      "description": "Fonte publica ou catalogo interno que justifica o fator aproximado."
    },
    "includes_vat": {
      "type": "boolean",
      "description": "Indica se o fator combina imposto sobre renda/contribuicao com VAT/IVA/ISS destacado."
    },
    "vat_pass_through_warning": {
      "type": "boolean",
      "description": "Indica se o estimate deve avisar que parte do imposto pode ser repassada ao cliente e nao reduzir margem."
    },
    "tax_regime_confidence": {
      "type": "string",
      "enum": ["high", "low"],
      "description": "high = usuário escolheu explicitamente; low = sugestão fallback ou 'outro'."
    },
    "pricing_models": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "escopo_fechado",
          "time_and_materials",
          "sprint",
          "retainer",
          "valor_fixo_por_entrega"
        ]
      }
    },
    "client_profile": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "microempresa",
          "pequena_empresa",
          "media_empresa",
          "enterprise",
          "governo",
          "cliente_internacional"
        ]
      },
      "description": "Pode ser vazio quando o usuário escolhe pular essa pergunta."
    },
    "billing_currency": {
      "type": ["string", "null"],
      "pattern": "^[A-Z]{3}$",
      "description": "Moeda em que o usuário cobra do cliente quando diferente de currency. null quando cobra na moeda local."
    },
    "exchange_rate_to_local": {
      "type": ["number", "null"],
      "exclusiveMinimum": 0,
      "description": "Câmbio manual: quantas unidades de currency valem 1 unidade de billing_currency. null quando não cobra em moeda estrangeira."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "hourly_rate_mode": { "const": "derivado" }
        }
      },
      "then": {
        "required": ["monthly_target_income", "billable_hours_per_month"]
      }
    }
  ]
}
