"""
Strategy Form Schemas.
"""

VISION_FORM = {
    "id": "create-vision-form",
    "title": "ایجاد چشم‌انداز",
    "apiEndpoint": "/api/v1/strategy/visions/",
    "method": "POST",
    "fields": [
        {"key": "title", "label": "عنوان", "type": "text", "required": True, "maxLength": 500},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
        {"key": "time_horizon_start", "label": "شروع افق زمانی", "type": "date", "required": False},
        {"key": "time_horizon_end", "label": "پایان افق زمانی", "type": "date", "required": False},
        {"key": "owner", "label": "مالک", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/access/users/"},
        {"key": "tags", "label": "برچسب‌ها", "type": "tags", "required": False},
    ],
}

STRATEGIC_THEME_FORM = {
    "id": "create-theme-form",
    "title": "ایجاد تم راهبردی",
    "apiEndpoint": "/api/v1/strategy/strategic-themes/",
    "method": "POST",
    "fields": [
        {"key": "vision", "label": "چشم‌انداز", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/visions/"},
        {"key": "name", "label": "نام", "type": "text", "required": True, "maxLength": 500},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
        {"key": "priority", "label": "اولویت", "type": "select", "required": True,
         "options": [
             {"value": "low", "label": "کم"},
             {"value": "medium", "label": "متوسط"},
             {"value": "high", "label": "زیاد"},
             {"value": "critical", "label": "بحرانی"},
         ]},
        {"key": "owner", "label": "مالک", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/access/users/"},
        {"key": "start_date", "label": "تاریخ شروع", "type": "date", "required": False},
        {"key": "end_date", "label": "تاریخ پایان", "type": "date", "required": False},
        {"key": "sort_order", "label": "ترتیب نمایش", "type": "number", "required": False, "default": 0},
        {"key": "tags", "label": "برچسب‌ها", "type": "tags", "required": False},
    ],
}

OBJECTIVE_FORM = {
    "id": "create-objective-form",
    "title": "ایجاد هدف",
    "apiEndpoint": "/api/v1/strategy/objectives/",
    "method": "POST",
    "fields": [
        {"key": "theme", "label": "تم راهبردی", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/strategy/strategic-themes/"},
        {"key": "parent", "label": "هدف مادر", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/strategy/objectives/"},
        {"key": "title", "label": "عنوان", "type": "text", "required": True, "maxLength": 500},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
        {"key": "level", "label": "سطح", "type": "select", "required": True,
         "options": [
             {"value": "enterprise", "label": "سازمانی"},
             {"value": "business_unit", "label": "واحد کسب‌وکار"},
             {"value": "department", "label": "دپارتمان"},
             {"value": "team", "label": "تیم"},
         ]},
        {"key": "time_frame", "label": "بازه زمانی", "type": "select", "required": True,
         "options": [
             {"value": "annual", "label": "سالانه"},
             {"value": "quarterly", "label": "سه‌ماهه"},
         ]},
        {"key": "period_start", "label": "شروع دوره", "type": "date", "required": False},
        {"key": "period_end", "label": "پایان دوره", "type": "date", "required": False},
        {"key": "weight", "label": "وزن", "type": "number", "required": False, "default": 1.0},
        {"key": "owner", "label": "مالک", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/access/users/"},
        {"key": "tags", "label": "برچسب‌ها", "type": "tags", "required": False},
    ],
}

KEY_RESULT_FORM = {
    "id": "create-key-result-form",
    "title": "ایجاد نتیجه کلیدی",
    "apiEndpoint": "/api/v1/strategy/key-results/",
    "method": "POST",
    "fields": [
        {"key": "objective", "label": "هدف", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/objectives/"},
        {"key": "title", "label": "عنوان", "type": "text", "required": True, "maxLength": 500},
        {"key": "metric_type", "label": "نوع سنجه", "type": "select", "required": True,
         "options": [
             {"value": "number", "label": "عددی"},
             {"value": "percentage", "label": "درصدی"},
             {"value": "currency", "label": "ارزی"},
             {"value": "boolean", "label": "بله/خیر"},
         ]},
        {"key": "start_value", "label": "مقدار شروع", "type": "number", "required": False, "default": 0},
        {"key": "target_value", "label": "مقدار هدف", "type": "number", "required": True},
        {"key": "weight", "label": "وزن", "type": "number", "required": False, "default": 1.0},
        {"key": "owner", "label": "مالک", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/access/users/"},
        {"key": "due_date", "label": "مهلت", "type": "date", "required": False},
    ],
}

CHECK_IN_FORM = {
    "id": "record-check-in-form",
    "title": "ثبت پیشرفت",
    "apiEndpoint": "/api/v1/strategy/check-ins/",
    "method": "POST",
    "fields": [
        {"key": "key_result", "label": "نتیجه کلیدی", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/key-results/"},
        {"key": "value", "label": "مقدار", "type": "number", "required": True},
        {"key": "confidence", "label": "سطح اطمینان", "type": "select", "required": True,
         "options": [
             {"value": "low", "label": "پایین"},
             {"value": "medium", "label": "متوسط"},
             {"value": "high", "label": "بالا"},
         ]},
        {"key": "notes", "label": "یادداشت", "type": "textarea", "required": False},
    ],
}

KPI_DEFINITION_FORM = {
    "id": "create-kpi-definition-form",
    "title": "ایجاد شاخص کلیدی عملکرد",
    "apiEndpoint": "/api/v1/strategy/kpi-definitions/",
    "method": "POST",
    "fields": [
        {"key": "name", "label": "نام", "type": "text", "required": True, "maxLength": 500},
        {"key": "code", "label": "کد", "type": "text", "required": True, "maxLength": 100},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
        {"key": "category", "label": "دسته‌بندی", "type": "text", "required": False},
        {"key": "unit_of_measure", "label": "واحد اندازه‌گیری", "type": "text", "required": False},
        {"key": "direction", "label": "جهت", "type": "select", "required": True,
         "options": [
             {"value": "higher_is_better", "label": "بالاتر بهتر"},
             {"value": "lower_is_better", "label": "پایین‌تر بهتر"},
             {"value": "target", "label": "هدف مشخص"},
         ]},
        {"key": "frequency", "label": "فراوانی", "type": "select", "required": True,
         "options": [
             {"value": "daily", "label": "روزانه"},
             {"value": "weekly", "label": "هفتگی"},
             {"value": "monthly", "label": "ماهانه"},
             {"value": "quarterly", "label": "سه‌ماهه"},
             {"value": "yearly", "label": "سالانه"},
         ]},
        {"key": "data_source", "label": "منبع داده", "type": "select", "required": True,
         "options": [
             {"value": "manual", "label": "دستی"},
             {"value": "calculated", "label": "محاسباتی"},
             {"value": "integrated", "label": "یکپارچه"},
         ]},
        {"key": "formula", "label": "فرمول محاسبه", "type": "textarea", "required": False},
        {"key": "threshold_red", "label": "آستانه قرمز", "type": "number", "required": False},
        {"key": "threshold_yellow", "label": "آستانه زرد", "type": "number", "required": False},
        {"key": "threshold_green", "label": "آستانه سبز", "type": "number", "required": False},
        {"key": "owner", "label": "مالک", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/access/users/"},
        {"key": "responsible_role", "label": "نقش مسئول", "type": "text", "required": False},
        {"key": "tags", "label": "برچسب‌ها", "type": "tags", "required": False},
    ],
}

KPI_TARGET_FORM = {
    "id": "create-kpi-target-form",
    "title": "ایجاد هدف‌گذاری KPI",
    "apiEndpoint": "/api/v1/strategy/kpi-targets/",
    "method": "POST",
    "fields": [
        {"key": "kpi", "label": "شاخص", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/kpi-definitions/"},
        {"key": "period_start", "label": "شروع دوره", "type": "date", "required": False},
        {"key": "period_end", "label": "پایان دوره", "type": "date", "required": False},
        {"key": "target_value", "label": "مقدار هدف", "type": "number", "required": True},
        {"key": "stretch_value", "label": "مقدار چالشی", "type": "number", "required": False},
        {"key": "notes", "label": "یادداشت", "type": "textarea", "required": False},
    ],
}

KPI_ACTUAL_FORM = {
    "id": "create-kpi-actual-form",
    "title": "ثبت مقدار واقعی KPI",
    "apiEndpoint": "/api/v1/strategy/kpi-actuals/",
    "method": "POST",
    "fields": [
        {"key": "kpi", "label": "شاخص", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/kpi-definitions/"},
        {"key": "period_start", "label": "شروع دوره", "type": "date", "required": False},
        {"key": "period_end", "label": "پایان دوره", "type": "date", "required": False},
        {"key": "actual_value", "label": "مقدار واقعی", "type": "number", "required": True},
        {"key": "notes", "label": "یادداشت", "type": "textarea", "required": False},
        {"key": "source", "label": "منبع", "type": "select", "required": False,
         "options": [
             {"value": "manual", "label": "دستی"},
             {"value": "system", "label": "سیستمی"},
             {"value": "integrated", "label": "یکپارچه"},
         ]},
    ],
}

KPI_ASSIGNMENT_FORM = {
    "id": "create-kpi-assignment-form",
    "title": "تخصیص KPI",
    "apiEndpoint": "/api/v1/strategy/kpi-assignments/",
    "method": "POST",
    "fields": [
        {"key": "kpi", "label": "شاخص", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/kpi-definitions/"},
        {"key": "level", "label": "سطح", "type": "select", "required": True,
         "options": [
             {"value": "portfolio", "label": "پورتفولیو"},
             {"value": "program", "label": "برنامه"},
             {"value": "project", "label": "پروژه"},
             {"value": "org_unit", "label": "واحد سازمانی"},
             {"value": "department", "label": "دپارتمان"},
             {"value": "team", "label": "تیم"},
         ]},
        {"key": "entity_id", "label": "شناسه موجودیت", "type": "text", "required": False},
        {"key": "weight", "label": "وزن", "type": "number", "required": False, "default": 1.0},
        {"key": "notes", "label": "یادداشت", "type": "textarea", "required": False},
    ],
}


# ═══════════════════════════════════════════════════
# Strategy Map Forms
# ═══════════════════════════════════════════════════

STRATEGY_MAP_FORM = {
    "id": "create-strategy-map-form",
    "title": "نقشه راهبردی",
    "apiEndpoint": "/api/v1/strategy/strategy-maps/",
    "method": "POST",
    "fields": [
        {"key": "name", "label": "نام", "type": "text", "required": True, "maxLength": 500},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
    ],
}

MAP_PERSPECTIVE_FORM = {
    "id": "create-map-perspective-form",
    "title": "دیدگاه نقشه",
    "apiEndpoint": "/api/v1/strategy/map-perspectives/",
    "method": "POST",
    "fields": [
        {"key": "strategy_map", "label": "نقشه راهبردی", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/strategy-maps/"},
        {"key": "name", "label": "نام", "type": "text", "required": True, "maxLength": 300},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
        {"key": "sort_order", "label": "ترتیب", "type": "number", "required": False, "default": 0},
        {"key": "color", "label": "رنگ", "type": "color", "required": False},
    ],
}

MAP_OBJECTIVE_FORM = {
    "id": "create-map-objective-form",
    "title": "هدف روی نقشه",
    "apiEndpoint": "/api/v1/strategy/map-objectives/",
    "method": "POST",
    "fields": [
        {"key": "strategy_map", "label": "نقشه راهبردی", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/strategy-maps/"},
        {"key": "perspective", "label": "دیدگاه", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/map-perspectives/"},
        {"key": "objective", "label": "هدف", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/objectives/"},
        {"key": "x_position", "label": "موقعیت X", "type": "number", "required": False, "default": 0},
        {"key": "y_position", "label": "موقعیت Y", "type": "number", "required": False, "default": 0},
    ],
}

CAUSAL_LINK_FORM = {
    "id": "create-causal-link-form",
    "title": "ارتباط علّی",
    "apiEndpoint": "/api/v1/strategy/causal-links/",
    "method": "POST",
    "fields": [
        {"key": "strategy_map", "label": "نقشه راهبردی", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/strategy-maps/"},
        {"key": "from_objective", "label": "از هدف", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/map-objectives/"},
        {"key": "to_objective", "label": "به هدف", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/map-objectives/"},
        {"key": "strength", "label": "قدرت", "type": "select", "required": False,
         "options": [
             {"value": "weak", "label": "ضعیف"},
             {"value": "medium", "label": "متوسط"},
             {"value": "strong", "label": "قوی"},
         ], "default": "medium"},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
    ],
}


# ═══════════════════════════════════════════════════
# Scorecard Forms
# ═══════════════════════════════════════════════════

SCORECARD_FORM = {
    "id": "create-scorecard-form",
    "title": "کارت امتیازی متوازن",
    "apiEndpoint": "/api/v1/strategy/scorecards/",
    "method": "POST",
    "fields": [
        {"key": "name", "label": "نام", "type": "text", "required": True},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
        {"key": "owner", "label": "مالک", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/users/"},
        {"key": "period_start", "label": "شروع دوره", "type": "date", "required": True},
        {"key": "period_end", "label": "پایان دوره", "type": "date", "required": True},
    ],
}


SC_PERSPECTIVE_FORM = {
    "id": "create-sc-perspective-form",
    "title": "دیدگاه کارت امتیازی",
    "apiEndpoint": "/api/v1/strategy/sc-perspectives/",
    "method": "POST",
    "fields": [
        {"key": "scorecard", "label": "کارت امتیازی", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/scorecards/"},
        {"key": "name", "label": "نام", "type": "text", "required": True},
        {"key": "weight", "label": "وزن", "type": "number", "required": True,
         "min": 0, "max": 1, "step": 0.01},
        {"key": "sort_order", "label": "ترتیب نمایش", "type": "number", "required": False, "default": 0},
    ],
}


SC_MEASURE_FORM = {
    "id": "create-sc-measure-form",
    "title": "سنجه کارت امتیازی",
    "apiEndpoint": "/api/v1/strategy/sc-measures/",
    "method": "POST",
    "fields": [
        {"key": "perspective", "label": "دیدگاه", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/sc-perspectives/"},
        {"key": "kpi_assignment", "label": "تخصیص KPI", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/kpi-assignments/"},
        {"key": "weight", "label": "وزن", "type": "number", "required": True,
         "min": 0, "max": 1, "step": 0.01},
        {"key": "target_value", "label": "مقدار هدف", "type": "number", "required": True},
        {"key": "actual_value", "label": "مقدار واقعی", "type": "number", "required": False, "default": 0},
    ],
}


# ═══════════════════════════════════════════════════
# Stage-Gate Governance Forms
# ═══════════════════════════════════════════════════

GATE_PROCESS_FORM = {
    "id": "create-gate-process-form",
    "title": "فرآیند Stage-Gate",
    "apiEndpoint": "/api/v1/strategy/gate-processes/",
    "method": "POST",
    "fields": [
        {"key": "name", "label": "نام", "type": "text", "required": True},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
        {"key": "applicable_to", "label": "قابل اعمال برای", "type": "select", "required": True,
         "options": [
             {"value": "project", "label": "پروژه"},
             {"value": "program", "label": "برنامه"},
         ], "default": "project"},
    ],
}


GATE_FORM = {
    "id": "create-gate-form",
    "title": "دروازه",
    "apiEndpoint": "/api/v1/strategy/gates/",
    "method": "POST",
    "fields": [
        {"key": "process", "label": "فرآیند", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/gate-processes/"},
        {"key": "name", "label": "نام", "type": "text", "required": True},
        {"key": "sequence", "label": "ترتیب", "type": "number", "required": True, "default": 0},
        {"key": "description", "label": "توضیحات", "type": "textarea", "required": False},
        {"key": "criteria", "label": "معیارها", "type": "textarea", "required": False},
    ],
}


GATE_REVIEW_FORM = {
    "id": "create-gate-review-form",
    "title": "بازبینی دروازه",
    "apiEndpoint": "/api/v1/strategy/gate-reviews/",
    "method": "POST",
    "fields": [
        {"key": "gate", "label": "دروازه", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/gates/"},
        {"key": "entity_id", "label": "شناسه موجودیت", "type": "text", "required": True},
        {"key": "entity_type", "label": "نوع موجودیت", "type": "select", "required": True,
         "options": [
             {"value": "project", "label": "پروژه"},
             {"value": "program", "label": "برنامه"},
         ], "default": "project"},
        {"key": "review_date", "label": "تاریخ بازبینی", "type": "date", "required": False},
        {"key": "notes", "label": "یادداشت‌ها", "type": "textarea", "required": False},
    ],
}


GATE_REVIEWER_FORM = {
    "id": "create-gate-reviewer-form",
    "title": "بازبین دروازه",
    "apiEndpoint": "/api/v1/strategy/gate-reviewers/",
    "method": "POST",
    "fields": [
        {"key": "review", "label": "بازبینی", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/gate-reviews/"},
        {"key": "user", "label": "کاربر", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/users/"},
        {"key": "role", "label": "نقش", "type": "text", "required": False},
    ],
}


GATE_DELIVERABLE_FORM = {
    "id": "create-gate-deliverable-form",
    "title": "تحویل‌دادنی دروازه",
    "apiEndpoint": "/api/v1/strategy/gate-deliverables/",
    "method": "POST",
    "fields": [
        {"key": "review", "label": "بازبینی", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/gate-reviews/"},
        {"key": "name", "label": "نام", "type": "text", "required": True},
        {"key": "document_id", "label": "شناسه سند", "type": "text", "required": False},
    ],
}


# ═══════════════════════════════════════════════════
# Corporate Policy Management Form Schemas
# ═══════════════════════════════════════════════════

POLICY_FORM = {
    "id": "create-policy-form",
    "title": "سیاست سازمانی",
    "apiEndpoint": "/api/v1/strategy/policies/",
    "method": "POST",
    "fields": [
        {"key": "title", "label": "عنوان", "type": "text", "required": True},
        {"key": "code", "label": "کد", "type": "text", "required": False},
        {"key": "category", "label": "دسته‌بندی", "type": "text", "required": False},
        {"key": "content", "label": "محتوا", "type": "textarea", "required": False},
        {"key": "effective_date", "label": "تاریخ اجرا", "type": "date", "required": False},
        {"key": "review_date", "label": "تاریخ بازنگری", "type": "date", "required": False},
        {"key": "owner", "label": "مالک", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/auth/users/"},
        {"key": "approver", "label": "تأییدکننده", "type": "select", "required": False,
         "optionsEndpoint": "/api/v1/auth/users/"},
        {"key": "document_id", "label": "شناسه سند", "type": "text", "required": False},
    ],
}

POLICY_ACK_FORM = {
    "id": "create-policy-ack-form",
    "title": "تأیید آشنایی سیاست",
    "apiEndpoint": "/api/v1/strategy/policy-acknowledgments/",
    "method": "POST",
    "fields": [
        {"key": "policy", "label": "سیاست", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/strategy/policies/"},
        {"key": "user", "label": "کاربر", "type": "select", "required": True,
         "optionsEndpoint": "/api/v1/auth/users/"},
        {"key": "acknowledged_at", "label": "تاریخ تأیید", "type": "datetime", "required": False},
    ],
}
