-- Update Case Details view to row/column layout
UPDATE detail_views
SET config = $$
{
  "name": "Case Details",
  "sources": [
    { "table": "clients", "foreignKey": "client_id", "alias": "client" }
  ],
  "rows": [
    {
      "classes": "grid grid-cols-4 gap-4",
      "columns": [
        {
          "classes": "card bg-base-100 shadow p-4 space-y-1",
          "elements": [
            { "type": "heading", "text": "Client Information" },
            { "type": "paragraph", "data_column": "client.name" },
            { "type": "paragraph", "data_column": "client.phone" },
            { "type": "paragraph", "data_column": "client.email" },
            { "type": "paragraph", "data_column": "client.address" },
            { "type": "paragraph", "data_column": "client.city" },
            { "type": "paragraph", "data_column": "client.country" },
            { "type": "paragraph", "data_column": "client.description" }
          ]
        },
        {
          "classes": "card bg-base-100 shadow p-4 space-y-1",
          "elements": [
            { "type": "heading", "data_column": "title" },
            { "type": "paragraph", "data_column": "case_number" },
            { "type": "paragraph", "data_column": "status" },
            { "type": "paragraph", "data_column": "lead_rep_name" },
            { "type": "paragraph", "data_column": "opened_at" },
            { "type": "paragraph", "data_column": "closed_at" }
          ]
        },
        {
          "classes": "space-y-1",
          "elements": [
            { "type": "aggregate", "table": "case_hours", "column": "hours", "function": "sum", "filterField": "case_id" },
            { "type": "aggregate", "table": "expenses", "column": "amount", "function": "sum", "filterField": "case_id" }
          ]
        },
        {
          "classes": "card bg-base-100 shadow p-4 space-y-1",
          "elements": [
            { "type": "paragraph", "data_column": "initial_instructions" }
          ]
        }
      ]
    }
  ]
}
$$
WHERE id = 2;

