{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "reversa-pricing-estimate-v1.1",
  "title": "Reversa Pricing Estimate",
  "description": "Estimativa de preço com três cenários (Esforço, Valor, Mercado) gerada pelo agente reversa-pricing-estimate.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "formula_versions",
    "created_at",
    "feature_dir",
    "profile_ref",
    "size_ref",
    "currency",
    "scenarios"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1.1"
    },
    "formula_versions": {
      "type": "object",
      "additionalProperties": false,
      "required": ["effort", "value", "market"],
      "properties": {
        "effort": { "type": "string", "pattern": "^\\d+\\.\\d+$" },
        "value": { "type": "string", "pattern": "^\\d+\\.\\d+$" },
        "market": { "type": "string", "pattern": "^\\d+\\.\\d+$" }
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "feature_dir": {
      "type": "string",
      "minLength": 1
    },
    "profile_ref": {
      "type": "string",
      "minLength": 1
    },
    "size_ref": {
      "type": "string",
      "minLength": 1
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "billing_currency": {
      "type": ["string", "null"],
      "pattern": "^[A-Z]{3}$"
    },
    "exchange_rate_to_local": {
      "type": ["number", "null"],
      "exclusiveMinimum": 0
    },
    "scenarios": {
      "type": "object",
      "additionalProperties": false,
      "required": ["effort", "value", "market"],
      "properties": {
        "effort": {
          "type": "object",
          "additionalProperties": false,
          "required": ["available"],
          "properties": {
            "available": { "type": "boolean" },
            "horas_min": { "type": "number", "minimum": 0 },
            "horas_max": { "type": "number", "minimum": 0 },
            "horas_estimadas": { "type": "number", "minimum": 0 },
            "seniority_factor": { "type": "number", "exclusiveMinimum": 0 },
            "custo_direto_min": { "type": "number", "minimum": 0 },
            "custo_direto_max": { "type": "number", "minimum": 0 },
            "custo_direto": { "type": "number", "minimum": 0 },
            "imposto_aproximado_min": { "type": "number", "minimum": 0 },
            "imposto_aproximado_max": { "type": "number", "minimum": 0 },
            "imposto_aproximado": { "type": "number", "minimum": 0 },
            "markup_aplicado_min": { "type": "number", "minimum": 0 },
            "markup_aplicado_max": { "type": "number", "minimum": 0 },
            "markup_aplicado": { "type": "number", "minimum": 0 },
            "preco_minimo": { "type": "number", "minimum": 0 },
            "preco_maximo": { "type": "number", "minimum": 0 },
            "preco_total": { "type": "number", "minimum": 0 },
            "explanation_pt_br": { "type": "string" }
          }
        },
        "value": {
          "type": "object",
          "additionalProperties": false,
          "required": ["available"],
          "properties": {
            "available": { "type": "boolean" },
            "monthly_return_declared": { "type": "number", "minimum": 0 },
            "users_impacted": { "type": "integer", "minimum": 0 },
            "cost_of_not_doing": { "type": "number", "minimum": 0 },
            "annual_value": { "type": "number", "minimum": 0 },
            "value_capture_min": { "type": "number", "minimum": 0, "maximum": 1 },
            "value_capture_recommended": { "type": "number", "minimum": 0, "maximum": 1 },
            "value_capture_max": { "type": "number", "minimum": 0, "maximum": 1 },
            "preco_minimo": { "type": "number", "minimum": 0 },
            "preco_recomendado": { "type": "number", "minimum": 0 },
            "preco_maximo": { "type": "number", "minimum": 0 },
            "payback_months_min": { "type": ["number", "null"], "minimum": 0 },
            "payback_months_max": { "type": ["number", "null"], "minimum": 0 },
            "explanation_pt_br": { "type": "string" }
          }
        },
        "market": {
          "type": "object",
          "additionalProperties": false,
          "required": ["available"],
          "properties": {
            "available": { "type": "boolean" },
            "country": { "type": "string", "pattern": "^[A-Z]{2}$" },
            "seniority": { "type": "string", "enum": ["junior", "mid", "senior", "staff_lead", "principal"] },
            "primary_pricing_model": { "type": "string" },
            "primary_client_profile": { "type": "string" },
            "complexity_class": { "type": "string", "enum": ["S", "M", "L", "XL", "XXL"] },
            "market_hourly_min": { "type": "number", "minimum": 0 },
            "market_hourly_max": { "type": "number", "minimum": 0 },
            "source_kind": { "type": "string" },
            "source_year": { "type": ["string", "number"] },
            "sources": {
              "type": "array",
              "items": { "type": "string", "minLength": 1 }
            },
            "preco_minimo": { "type": "number", "minimum": 0 },
            "preco_maximo": { "type": "number", "minimum": 0 },
            "fallback_applied": { "type": "boolean" },
            "explanation_pt_br": { "type": "string" }
          }
        }
      }
    },
    "guidance_pt_br": { "type": "string" }
  }
}
