{
  "schemaVersion": "1.0",
  "id": "calendar-month",
  "title": "Lịch chung",
  "purpose": "Month grid với agenda ngày chọn và điều hướng tháng.",
  "roles": [
    "adult"
  ],
  "group": "calendar-scheduling",
  "variantOf": "calendar-list",
  "layout": {
    "canvas": {
      "width": 390,
      "height": 844
    },
    "responsive": {
      "minimumWidth": 360,
      "maximumWidth": 430,
      "scroll": "vertical",
      "safeAreaBottom": true,
      "fontScale": "native dynamic type; reflow without clipping",
      "keyboard": "composer sticky within resized viewport; dialog scrolls; no fixed keyboard overlay"
    },
    "regions": [
      {
        "id": "header",
        "order": 0,
        "type": "safe-area/header",
        "height": "intrinsic"
      },
      {
        "id": "content",
        "order": 1,
        "type": "purpose-specific schedule",
        "componentIds": [
          "screen-header",
          "calendar-month-0",
          "calendar-month-1",
          "calendar-month-2",
          "calendar-month-3",
          "screen-actions",
          "primary-navigation"
        ]
      },
      {
        "id": "actions",
        "order": 2,
        "type": "one primary + secondary controls"
      },
      {
        "id": "navigation",
        "order": 3,
        "type": "adult-four-tabs"
      }
    ]
  },
  "components": [
    {
      "id": "screen-header",
      "type": "Header",
      "props": {
        "homeLabel": "Nhà Lá",
        "scopeGate": "A",
        "backTarget": "calendar-list",
        "settingsTarget": "settings"
      },
      "tokens": {
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Thanh đầu màn hình",
        "readingOrder": 0,
        "focusOrder": "back then settings"
      }
    },
    {
      "id": "calendar-month-0",
      "type": "CalendarMode",
      "props": {
        "modes": [
          "list",
          "calendar"
        ],
        "selected": "calendar",
        "sharedContext": [
          "selectedDate",
          "member",
          "status",
          "space"
        ]
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Lịch chung · CalendarMode",
        "readingOrder": 1,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "calendar-month-1",
      "type": "MonthGrid",
      "props": {
        "selectedDate": "2026-10-14",
        "firstWeekday": 1,
        "cellMinTarget": 48,
        "dateNotTimestamp": true,
        "dotDates": [
          "2026-10-13",
          "2026-10-14"
        ]
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Lịch chung · MonthGrid",
        "readingOrder": 2,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "calendar-month-2",
      "type": "CalendarFilterSummary",
      "props": {
        "target": "calendar-filters",
        "sharedContext": [
          "member",
          "status",
          "space"
        ],
        "compact": true
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Lịch chung · CalendarFilterSummary",
        "readingOrder": 3,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "calendar-month-3",
      "type": "DayAgenda",
      "props": {
        "selectedDate": "2026-10-14",
        "occurrenceIds": [
          "occ-dishes",
          "occ-blanket",
          "occ-plants"
        ],
        "sameSourceAsList": true
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Lịch chung · DayAgenda",
        "readingOrder": 4,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "navigate-0",
            "label": "Mở chi tiết ngày",
            "kind": "navigate",
            "target": "calendar-day",
            "confirmationRequired": false
          },
          {
            "id": "navigate-1",
            "label": "Nhờ trợ lý",
            "kind": "navigate",
            "target": "ai-chat",
            "confirmationRequired": false
          },
          {
            "id": "link-calendar-list",
            "label": "Lịch chung",
            "kind": "navigate",
            "target": "calendar-list",
            "confirmationRequired": false
          },
          {
            "id": "link-settings",
            "label": "Cài đặt",
            "kind": "navigate",
            "target": "settings",
            "confirmationRequired": false
          },
          {
            "id": "link-calendar-month",
            "label": "Lịch chung",
            "kind": "navigate",
            "target": "calendar-month",
            "confirmationRequired": false
          },
          {
            "id": "link-calendar-filters",
            "label": "Lọc lịch",
            "kind": "navigate",
            "target": "calendar-filters",
            "confirmationRequired": false
          },
          {
            "id": "link-task-detail",
            "label": "Rửa bát sau bữa tối",
            "kind": "navigate",
            "target": "task-detail",
            "confirmationRequired": false
          },
          {
            "id": "link-submission-review",
            "label": "Bông đã tưới cây",
            "kind": "navigate",
            "target": "submission-review",
            "confirmationRequired": false
          },
          {
            "id": "link-today",
            "label": "Hôm nay",
            "kind": "navigate",
            "target": "today",
            "confirmationRequired": false
          },
          {
            "id": "link-spaces",
            "label": "Không gian",
            "kind": "navigate",
            "target": "spaces",
            "confirmationRequired": false
          },
          {
            "id": "link-members",
            "label": "Thành viên",
            "kind": "navigate",
            "target": "members",
            "confirmationRequired": false
          },
          {
            "id": "month-prev",
            "label": "Tháng trước",
            "kind": "select",
            "target": null,
            "confirmationRequired": false
          },
          {
            "id": "month-next",
            "label": "Tháng sau",
            "kind": "select",
            "target": null,
            "confirmationRequired": false
          },
          {
            "id": "select-date",
            "label": "Chọn ngày",
            "kind": "select",
            "target": null,
            "confirmationRequired": false
          },
          {
            "id": "complete",
            "label": "Hoàn thành việc của tôi",
            "kind": "mutate",
            "target": null,
            "confirmationRequired": false
          }
        ],
        "primaryCount": 0
      },
      "tokens": {
        "lightBackground": "{component.light.button.background}",
        "lightForeground": "{component.light.button.foreground}",
        "darkBackground": "{component.dark.button.background}",
        "darkForeground": "{component.dark.button.foreground}",
        "height": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Hành động của màn hình",
        "keyboard": true,
        "focusVisible": true,
        "disabledOnlyLowContrast": true
      }
    },
    {
      "id": "primary-navigation",
      "type": "Navigation",
      "props": {
        "items": [
          [
            "today",
            "Hôm nay",
            "home"
          ],
          [
            "spaces",
            "Không gian",
            "room"
          ],
          [
            "calendar-list",
            "Lịch",
            "calendar"
          ],
          [
            "members",
            "Thành viên",
            "users"
          ]
        ],
        "active": "calendar-list"
      },
      "tokens": {
        "activeBackground": "{semantic.light.sage}",
        "activeDarkBackground": "{semantic.dark.sage}",
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Điều hướng chính",
        "ariaCurrent": "page",
        "touchTarget": 48,
        "noColorOnly": true
      }
    }
  ],
  "fields": [],
  "states": [
    {
      "id": "calendar",
      "when": "mode=calendar",
      "visibleUI": "7 cột ≥48 tại360; giữ date/filter",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "link-calendar-list",
        "link-settings",
        "link-calendar-month",
        "link-calendar-filters",
        "link-task-detail",
        "link-submission-review",
        "link-today",
        "link-spaces",
        "link-members",
        "month-prev",
        "month-next",
        "select-date",
        "complete"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "selected-day",
      "when": "Tap ngày",
      "visibleUI": "Agenda same occurrences",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "link-calendar-list",
        "link-settings",
        "link-calendar-month",
        "link-calendar-filters",
        "link-task-detail",
        "link-submission-review",
        "link-today",
        "link-spaces",
        "link-members",
        "month-prev",
        "month-next",
        "select-date",
        "complete"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "month-change",
      "when": "Previous/next month",
      "visibleUI": "Bounded windows tối đa14 ngày mỗi request",
      "availableActions": [
        "navigate-0",
        "navigate-1",
        "link-calendar-list",
        "link-settings",
        "link-calendar-month",
        "link-calendar-filters",
        "link-task-detail",
        "link-submission-review",
        "link-today",
        "link-spaces",
        "link-members",
        "month-prev",
        "month-next",
        "select-date",
        "complete"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "navigate-0",
      "label": "Mở chi tiết ngày",
      "kind": "navigate",
      "targetScreenId": "calendar-day",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "navigate-1",
      "label": "Nhờ trợ lý",
      "kind": "navigate",
      "targetScreenId": "ai-chat",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": null
    },
    {
      "id": "link-calendar-list",
      "label": "Lịch chung",
      "kind": "navigate",
      "targetScreenId": "calendar-list",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-settings",
      "label": "Cài đặt",
      "kind": "navigate",
      "targetScreenId": "settings",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-calendar-month",
      "label": "Lịch chung",
      "kind": "navigate",
      "targetScreenId": "calendar-month",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-calendar-filters",
      "label": "Lọc lịch",
      "kind": "navigate",
      "targetScreenId": "calendar-filters",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-task-detail",
      "label": "Rửa bát sau bữa tối",
      "kind": "navigate",
      "targetScreenId": "task-detail",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-submission-review",
      "label": "Bông đã tưới cây",
      "kind": "navigate",
      "targetScreenId": "submission-review",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-today",
      "label": "Hôm nay",
      "kind": "navigate",
      "targetScreenId": "today",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-spaces",
      "label": "Không gian",
      "kind": "navigate",
      "targetScreenId": "spaces",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-members",
      "label": "Thành viên",
      "kind": "navigate",
      "targetScreenId": "members",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "month-prev",
      "label": "Tháng trước",
      "kind": "select",
      "targetScreenId": null,
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local view context"
    },
    {
      "id": "month-next",
      "label": "Tháng sau",
      "kind": "select",
      "targetScreenId": null,
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local view context"
    },
    {
      "id": "select-date",
      "label": "Chọn ngày",
      "kind": "select",
      "targetScreenId": null,
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local view context"
    },
    {
      "id": "complete",
      "label": "Hoàn thành việc của tôi",
      "kind": "mutate",
      "targetScreenId": null,
      "permission": "A assigned=self",
      "confirmationRequired": false,
      "contractRef": "POST /v1/households/{hid}/occurrences/{oid}/complete"
    }
  ],
  "dataBindings": [
    {
      "source": "GET /v1/households/{hid}/schedule",
      "shape": {
        "from_local_date": "date",
        "to_local_date": "date (window<=14)",
        "assignments": "PublishedAssignmentDto[]",
        "occurrences": "OccurrenceDto[]",
        "viewContext": "local {mode,selectedDate,member,status,space}"
      },
      "sample": {
        "from_local_date": "2026-10-14",
        "to_local_date": "2026-10-20",
        "assignments": [],
        "occurrences": [],
        "viewContext": {
          "mode": "calendar",
          "selectedDate": "2026-10-14",
          "member": "an",
          "status": "all",
          "space": "all"
        }
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Lịch chung",
    "primary": null,
    "empty": null,
    "notices": [],
    "locale": "vi",
    "demoLabel": "Bản thiết kế · dữ liệu mẫu · không kết nối dịch vụ"
  },
  "implementation": {
    "nativeRoute": "/design/calendar-month",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "copyAuthority": "Use copy and component UI props for interface text; permission, state conditions and implementation notes are not user-facing copy",
    "apiRefs": [
      "GET /v1/households/{hid}/schedule"
    ],
    "newContractRefs": [],
    "notes": [
      "Tất cả ví dụ là dữ liệu thiết kế, không bằng chứng native/API/store đã chạy.",
      "Native route dưới đây là đề xuất mapping cho agent, không tuyên bố route source đã tồn tại.",
      "Mọi mutation dùng envelope {data,version,household_revision,replayed}, stable Idempotency-Key và expected_version khi sửa."
    ],
    "integrationStatus": "design complete; local static/draft interactions; native/API adapters pending",
    "sourceAuthority": [
      "docs/product-brief.md",
      "plans/261013-1409-sweepy-vietnam-mobile/mobile-flows.md",
      "plans/261013-1409-sweepy-vietnam-mobile/api-contracts.md",
      "packages/domain/src/contracts/phase2.ts",
      "packages/domain/src/index.ts",
      "packages/domain/src/contracts/phase3.ts",
      "packages/domain/src/contracts/billing.ts",
      "apps/mobile/src/lib/api.ts"
    ],
    "capability": "A",
    "errors": {
      "401": "Stop queue; adult login or child re-pair without parent account.",
      "403": "Do not retry lost capability. FEATURE_REQUIRED never grants Pro.",
      "409": "Fetch canonical scoped state; review/reconfirm new intent, do not rewrite old replay payload.",
      "422": "Field error with retained draft.",
      "429": "Respect Retry-After.",
      "503": "Backoff only retryable commands with original key."
    }
  }
}
