// 생산기준관리 Config
// 작업지시, 작업자화면, 설비, 라인/작업장, BOM 기준 통합 관리

// MasterConfigurationManager 호환 형식으로 변환
const productionMasterConfig = {
  id: 'production',
  title: '생산기준 관리',
  description: '생산 관련 기준정보를 통합 관리합니다',
  icon: 'Factory',
  tabs: [
    { id: 'hierarchy', label: '계층구조', icon: 'GitBranch' },
    { id: 'section', label: '섹션', icon: 'Layers' },
    { id: 'field', label: '항목', icon: 'ClipboardList' },
    { id: 'attribute', label: '속성', icon: 'Settings' },
  ],
  // 생산기준 유형 (작업지시, 작업자화면, 설비, 라인, BOM)
  entityTypes: [
    { id: 1, code: 'WO', name: '작업지시', description: '작업지시 기준관리', sortOrder: 1, isActive: true },
    { id: 2, code: 'WS', name: '작업자화면', description: '작업자화면 기준관리', sortOrder: 2, isActive: true },
    { id: 3, code: 'EQ', name: '설비', description: '설비 기준관리', sortOrder: 3, isActive: true },
    { id: 4, code: 'LN', name: '라인/작업장', description: '라인/작업장 기준관리', sortOrder: 4, isActive: true },
    { id: 5, code: 'BOM', name: 'BOM', description: 'BOM 기준관리', sortOrder: 5, isActive: true },
  ],
  // 카테고리 (공정별 분류)
  categories: [
    { id: 1, code: 'SCREEN', name: '스크린 공정', parentId: null, level: 1, path: '/1', sortOrder: 1 },
    { id: 2, code: 'SLAT', name: '슬랫 공정', parentId: null, level: 1, path: '/2', sortOrder: 2 },
    { id: 3, code: 'FOLD', name: '절곡 공정', parentId: null, level: 1, path: '/3', sortOrder: 3 },
    { id: 4, code: 'STOCK', name: '재고생산', parentId: null, level: 1, path: '/4', sortOrder: 4 },
    { id: 5, code: 'LINE-A', name: 'A라인', parentId: 1, level: 2, path: '/1/5', sortOrder: 1 },
    { id: 6, code: 'LINE-B', name: 'B라인', parentId: 2, level: 2, path: '/2/6', sortOrder: 1 },
    { id: 7, code: 'LINE-C', name: 'C라인', parentId: 3, level: 2, path: '/3/7', sortOrder: 1 },
  ],
  // 통합 필드 정의
  masterFields: [
    // 작업지시 필드
    { id: 1, fieldKey: 'workOrderNo', fieldName: '작업지시번호', inputType: 'text', isRequired: true, description: '자동 채번 (KD-WO-YYMMDD-##)' },
    { id: 2, fieldKey: 'workOrderType', fieldName: '작업지시유형', inputType: 'select', isRequired: true, options: { items: ['스크린', '슬랫', '절곡', '재고생산'] }, description: '공정별 작업지시 유형' },
    { id: 3, fieldKey: 'orderId', fieldName: '수주번호', inputType: 'reference', isRequired: true, description: '연결된 수주 정보' },
    { id: 4, fieldKey: 'processCode', fieldName: '공정', inputType: 'reference', isRequired: true, description: '작업 공정' },
    { id: 5, fieldKey: 'siteName', fieldName: '현장명', inputType: 'text', isRequired: true, description: '수주의 현장 정보' },
    { id: 6, fieldKey: 'productName', fieldName: '제품명', inputType: 'text', isRequired: true, description: '생산할 제품' },
    { id: 7, fieldKey: 'specification', fieldName: '규격', inputType: 'text', isRequired: true, description: '제품 규격 (W×H)' },
    { id: 8, fieldKey: 'totalQty', fieldName: '지시수량', inputType: 'number', isRequired: true, description: '생산 지시 수량' },
    { id: 9, fieldKey: 'completedQty', fieldName: '완료수량', inputType: 'number', isRequired: false, description: '생산 완료 수량' },
    { id: 10, fieldKey: 'instructionDate', fieldName: '지시일', inputType: 'date', isRequired: true, description: '작업지시 발행일' },
    { id: 11, fieldKey: 'dueDate', fieldName: '납기일', inputType: 'date', isRequired: true, description: '생산 완료 목표일' },
    { id: 12, fieldKey: 'workPriority', fieldName: '우선순위', inputType: 'select', isRequired: true, options: { items: ['1-긴급', '2-높음', '3-보통', '4-낮음'] }, description: '작업 우선순위' },
    { id: 13, fieldKey: 'assignee', fieldName: '작업자', inputType: 'reference', isRequired: false, description: '배정된 작업자' },
    { id: 14, fieldKey: 'status', fieldName: '상태', inputType: 'select', isRequired: true, options: { items: ['대기', '배정완료', '진행중', '일시중단', '완료', '취소'] }, description: '작업지시 상태' },
    // 설비 필드
    { id: 15, fieldKey: 'equipmentCode', fieldName: '설비코드', inputType: 'text', isRequired: true, description: '설비 고유 코드' },
    { id: 16, fieldKey: 'equipmentName', fieldName: '설비명', inputType: 'text', isRequired: true, description: '설비 이름' },
    { id: 17, fieldKey: 'equipmentCategory', fieldName: '설비분류', inputType: 'select', isRequired: true, options: { items: ['절단설비', '성형설비', '봉제설비', '포장설비', '검사장비'] }, description: '설비 분류' },
    { id: 18, fieldKey: 'location', fieldName: '설치위치', inputType: 'text', isRequired: true, description: '설비 설치 위치' },
    // 라인 필드
    { id: 19, fieldKey: 'lineCode', fieldName: '라인코드', inputType: 'text', isRequired: true, description: '라인 고유 코드' },
    { id: 20, fieldKey: 'lineName', fieldName: '라인명', inputType: 'text', isRequired: true, description: '라인 이름' },
    { id: 21, fieldKey: 'factoryId', fieldName: '공장', inputType: 'select', isRequired: true, options: { items: ['1공장', '2공장', '3공장'] }, description: '소속 공장' },
    { id: 22, fieldKey: 'capacity', fieldName: '일생산능력', inputType: 'number', isRequired: true, description: '일일 생산 능력' },
    // BOM 필드
    { id: 23, fieldKey: 'bomCode', fieldName: 'BOM코드', inputType: 'text', isRequired: true, description: 'BOM 고유 코드' },
    { id: 24, fieldKey: 'productCode', fieldName: '제품코드', inputType: 'reference', isRequired: true, description: '제품 코드' },
    { id: 25, fieldKey: 'version', fieldName: '버전', inputType: 'text', isRequired: true, description: 'BOM 버전' },
    { id: 26, fieldKey: 'effectiveDate', fieldName: '적용시작일', inputType: 'date', isRequired: true, description: '적용 시작일' },
  ],
  // 섹션 정의
  masterSections: [
    { id: 1, sectionKey: 'workOrderBasic', sectionName: '작업지시 기본정보', sectionType: 'general', applicableTypes: ['WO'], description: '작업지시 기본 정보', fields: [1, 2, 3, 4, 5] },
    { id: 2, sectionKey: 'workOrderProduct', sectionName: '제품정보', sectionType: 'general', applicableTypes: ['WO'], description: '생산 제품 정보', fields: [6, 7, 8, 9] },
    { id: 3, sectionKey: 'workOrderSchedule', sectionName: '일정정보', sectionType: 'general', applicableTypes: ['WO'], description: '작업 일정 정보', fields: [10, 11, 12, 13, 14] },
    { id: 4, sectionKey: 'equipmentBasic', sectionName: '설비 기본정보', sectionType: 'general', applicableTypes: ['EQ'], description: '설비 기본 정보', fields: [15, 16, 17, 18] },
    { id: 5, sectionKey: 'lineBasic', sectionName: '라인 기본정보', sectionType: 'general', applicableTypes: ['LN'], description: '라인 기본 정보', fields: [19, 20, 21, 22] },
    { id: 6, sectionKey: 'bomBasic', sectionName: 'BOM 기본정보', sectionType: 'general', applicableTypes: ['BOM'], description: 'BOM 기본 정보', fields: [23, 24, 25, 26] },
  ],
  // 페이지 템플릿
  pageTemplates: [
    {
      id: 1,
      pageCode: 'work_order_list',
      pageName: '작업지시 목록',
      pagePath: '/생산관리/작업지시_목록',
      pageType: 'list',
      itemTypes: ['WO'],
      sections: [
        { sectionId: 1, sectionKey: 'searchFilter', sectionName: '검색조건', sortOrder: 1, fields: [] },
        { sectionId: 2, sectionKey: 'reportCards', sectionName: '리포트카드', sortOrder: 2, fields: [] },
        { sectionId: 3, sectionKey: 'dataTable', sectionName: '목록테이블', sortOrder: 3, fields: [] },
      ],
      conditions: [],
    },
    {
      id: 2,
      pageCode: 'work_order_register',
      pageName: '작업지시 등록',
      pagePath: '/생산관리/작업지시_등록',
      pageType: 'form',
      itemTypes: ['WO'],
      sections: [
        { sectionId: 1, sectionKey: 'workOrderBasic', sectionName: '기본정보', sortOrder: 1, fields: [
          { fieldId: 1, fieldKey: 'workOrderNo', fieldName: '작업지시번호', inputType: 'text', isRequired: true },
          { fieldId: 2, fieldKey: 'workOrderType', fieldName: '작업지시유형', inputType: 'select', isRequired: true },
          { fieldId: 3, fieldKey: 'orderId', fieldName: '수주번호', inputType: 'reference', isRequired: true },
        ]},
        { sectionId: 2, sectionKey: 'workOrderProduct', sectionName: '제품정보', sortOrder: 2, fields: [
          { fieldId: 6, fieldKey: 'productName', fieldName: '제품명', inputType: 'text', isRequired: true },
          { fieldId: 7, fieldKey: 'specification', fieldName: '규격', inputType: 'text', isRequired: true },
          { fieldId: 8, fieldKey: 'totalQty', fieldName: '지시수량', inputType: 'number', isRequired: true },
        ]},
        { sectionId: 3, sectionKey: 'workOrderSchedule', sectionName: '일정정보', sortOrder: 3, fields: [
          { fieldId: 10, fieldKey: 'instructionDate', fieldName: '지시일', inputType: 'date', isRequired: true },
          { fieldId: 11, fieldKey: 'dueDate', fieldName: '납기일', inputType: 'date', isRequired: true },
          { fieldId: 12, fieldKey: 'workPriority', fieldName: '우선순위', inputType: 'select', isRequired: true },
        ]},
      ],
      conditions: [],
    },
    {
      id: 3,
      pageCode: 'equipment_list',
      pageName: '설비 목록',
      pagePath: '/생산관리/설비_목록',
      pageType: 'list',
      itemTypes: ['EQ'],
      sections: [
        { sectionId: 1, sectionKey: 'equipmentBasic', sectionName: '설비정보', sortOrder: 1, fields: [] },
      ],
      conditions: [],
    },
    {
      id: 4,
      pageCode: 'line_list',
      pageName: '라인/작업장 목록',
      pagePath: '/생산관리/라인_목록',
      pageType: 'list',
      itemTypes: ['LN'],
      sections: [
        { sectionId: 1, sectionKey: 'lineBasic', sectionName: '라인정보', sortOrder: 1, fields: [] },
      ],
      conditions: [],
    },
    {
      id: 5,
      pageCode: 'bom_list',
      pageName: 'BOM 목록',
      pagePath: '/생산관리/BOM_목록',
      pageType: 'list',
      itemTypes: ['BOM'],
      sections: [
        { sectionId: 1, sectionKey: 'bomBasic', sectionName: 'BOM정보', sortOrder: 1, fields: [] },
      ],
      conditions: [],
    },
  ],

  // ============ 상세 데이터 (기존 구조 유지) ============

  // ============ 1. 작업지시 기준관리 상세 ============
  workOrderMaster: {
    id: 'work-order-master',
    title: '작업지시 기준관리',
    description: '작업지시서 페이지, 섹션, 항목을 관리합니다',
    icon: 'ClipboardList',
    tabs: [
      { id: 'page', label: '페이지', icon: 'FileText' },
      { id: 'section', label: '섹션', icon: 'Layers' },
      { id: 'field', label: '항목', icon: 'List' },
      { id: 'workflow', label: '워크플로우', icon: 'GitBranch' },
    ],

    // 작업지시 유형
    workOrderTypes: [
      { id: 1, code: 'SCREEN', name: '스크린 작업지시', prefix: 'KD-WO-SCR', description: '스크린 공정 작업지시', sortOrder: 1, isActive: true },
      { id: 2, code: 'SLAT', name: '슬랫 작업지시', prefix: 'KD-WO-SLT', description: '슬랫 공정 작업지시', sortOrder: 2, isActive: true },
      { id: 3, code: 'FOLD', name: '절곡 작업지시', prefix: 'KD-WO-FLD', description: '절곡 공정 작업지시', sortOrder: 3, isActive: true },
      { id: 4, code: 'STOCK', name: '재고생산 작업지시', prefix: 'KD-WO-STK', description: '재고용 부품 생산 작업지시', sortOrder: 4, isActive: true },
    ],

    // 작업지시 상태
    workOrderStatuses: [
      { id: 1, code: 'DRAFT', name: '작성중', color: 'gray', sortOrder: 1 },
      { id: 2, code: 'PENDING', name: '대기', color: 'yellow', sortOrder: 2 },
      { id: 3, code: 'ASSIGNED', name: '배정완료', color: 'blue', sortOrder: 3 },
      { id: 4, code: 'IN_PROGRESS', name: '진행중', color: 'green', sortOrder: 4 },
      { id: 5, code: 'PAUSED', name: '일시중단', color: 'orange', sortOrder: 5 },
      { id: 6, code: 'COMPLETED', name: '완료', color: 'emerald', sortOrder: 6 },
      { id: 7, code: 'CANCELLED', name: '취소', color: 'red', sortOrder: 7 },
    ],

    // 작업지시 필드 정의
    masterFields: [
      { id: 1, fieldKey: 'workOrderNo', fieldName: '작업지시번호', inputType: 'text', isRequired: true, readOnly: true, description: '자동 채번 (KD-WO-YYMMDD-##)' },
      { id: 2, fieldKey: 'workOrderType', fieldName: '작업지시유형', inputType: 'select', isRequired: true, options: { items: ['스크린', '슬랫', '절곡', '재고생산'] }, description: '공정별 작업지시 유형' },
      { id: 3, fieldKey: 'orderId', fieldName: '수주번호', inputType: 'reference', isRequired: true, refType: 'order', description: '연결된 수주 정보' },
      { id: 4, fieldKey: 'processCode', fieldName: '공정', inputType: 'reference', isRequired: true, refType: 'process', description: '작업 공정' },
      { id: 5, fieldKey: 'siteName', fieldName: '현장명', inputType: 'text', isRequired: true, description: '수주의 현장 정보 (자동)' },
      { id: 6, fieldKey: 'productName', fieldName: '제품명', inputType: 'text', isRequired: true, description: '생산할 제품' },
      { id: 7, fieldKey: 'specification', fieldName: '규격', inputType: 'text', isRequired: true, description: '제품 규격 (W×H)' },
      { id: 8, fieldKey: 'totalQty', fieldName: '지시수량', inputType: 'number', isRequired: true, validations: { min: 1 }, description: '생산 지시 수량' },
      { id: 9, fieldKey: 'completedQty', fieldName: '완료수량', inputType: 'number', isRequired: false, readOnly: true, description: '생산 완료 수량' },
      { id: 10, fieldKey: 'defectQty', fieldName: '불량수량', inputType: 'number', isRequired: false, readOnly: true, description: '불량 발생 수량' },
      { id: 11, fieldKey: 'instructionDate', fieldName: '지시일', inputType: 'date', isRequired: true, description: '작업지시 발행일' },
      { id: 12, fieldKey: 'dueDate', fieldName: '납기일', inputType: 'date', isRequired: true, description: '생산 완료 목표일' },
      { id: 13, fieldKey: 'workPriority', fieldName: '우선순위', inputType: 'select', isRequired: true, options: { items: ['1-긴급', '2-높음', '3-보통', '4-낮음'] }, description: '작업 우선순위' },
      { id: 14, fieldKey: 'assignee', fieldName: '작업자', inputType: 'reference', isRequired: false, refType: 'worker', description: '배정된 작업자' },
      { id: 15, fieldKey: 'status', fieldName: '상태', inputType: 'select', isRequired: true, options: { items: ['대기', '배정완료', '진행중', '일시중단', '완료', '취소'] }, description: '작업지시 상태' },
      { id: 16, fieldKey: 'materialLotNo', fieldName: '자재LOT', inputType: 'reference', isRequired: false, refType: 'materialLot', description: '투입 자재 LOT 번호' },
      { id: 17, fieldKey: 'note', fieldName: '비고', inputType: 'textarea', isRequired: false, description: '특이사항' },
    ],

    // 작업지시 섹션 정의
    masterSections: [
      { id: 1, sectionKey: 'basicInfo', sectionName: '기본정보', sortOrder: 1, description: '작업지시 기본 정보', fields: [1, 2, 3, 4, 5] },
      { id: 2, sectionKey: 'productInfo', sectionName: '제품정보', sortOrder: 2, description: '생산 제품 정보', fields: [6, 7, 8, 9, 10] },
      { id: 3, sectionKey: 'scheduleInfo', sectionName: '일정정보', sortOrder: 3, description: '작업 일정 정보', fields: [11, 12, 13] },
      { id: 4, sectionKey: 'assignInfo', sectionName: '배정정보', sortOrder: 4, description: '작업자/자재 배정', fields: [14, 15, 16, 17] },
    ],

    // 페이지 템플릿
    pageTemplates: [
      {
        id: 1,
        pageCode: 'work_order_list',
        pageName: '작업지시 목록',
        pagePath: '/생산관리/작업지시_목록',
        pageType: 'list',
        sections: [
          { sectionKey: 'searchFilter', sectionName: '검색조건', sortOrder: 1 },
          { sectionKey: 'reportCards', sectionName: '리포트카드', sortOrder: 2 },
          { sectionKey: 'dataTable', sectionName: '목록테이블', sortOrder: 3 },
        ],
        columns: ['workOrderNo', 'workOrderType', 'siteName', 'productName', 'totalQty', 'status', 'dueDate', 'assignee'],
      },
      {
        id: 2,
        pageCode: 'work_order_register',
        pageName: '작업지시 등록',
        pagePath: '/생산관리/작업지시_등록',
        pageType: 'form',
        sections: [
          { sectionKey: 'basicInfo', sectionName: '기본정보', sortOrder: 1 },
          { sectionKey: 'productInfo', sectionName: '제품정보', sortOrder: 2 },
          { sectionKey: 'scheduleInfo', sectionName: '일정정보', sortOrder: 3 },
          { sectionKey: 'assignInfo', sectionName: '배정정보', sortOrder: 4 },
        ],
      },
      {
        id: 3,
        pageCode: 'work_order_detail',
        pageName: '작업지시 상세',
        pagePath: '/생산관리/작업지시_상세',
        pageType: 'detail',
        sections: [
          { sectionKey: 'basicInfo', sectionName: '기본정보', sortOrder: 1 },
          { sectionKey: 'productInfo', sectionName: '제품정보', sortOrder: 2 },
          { sectionKey: 'scheduleInfo', sectionName: '일정정보', sortOrder: 3 },
          { sectionKey: 'processStatus', sectionName: '공정진행현황', sortOrder: 4 },
          { sectionKey: 'workHistory', sectionName: '작업이력', sortOrder: 5 },
        ],
      },
    ],
  },

  // ============ 2. 작업자화면 기준관리 ============
  workerScreenMaster: {
    id: 'worker-screen-master',
    title: '작업자화면 기준관리',
    description: '작업자 화면의 페이지, 섹션, 항목을 관리합니다',
    icon: 'User',
    tabs: [
      { id: 'page', label: '페이지', icon: 'FileText' },
      { id: 'section', label: '섹션', icon: 'Layers' },
      { id: 'field', label: '항목', icon: 'List' },
      { id: 'action', label: '액션버튼', icon: 'MousePointer' },
    ],

    // 작업자 역할
    workerRoles: [
      { id: 1, code: 'OPERATOR', name: '작업자', description: '일반 생산 작업자', permissions: ['view', 'start', 'progress', 'complete'] },
      { id: 2, code: 'LEAD', name: '조장', description: '라인 조장', permissions: ['view', 'start', 'progress', 'complete', 'assign', 'pause'] },
      { id: 3, code: 'SUPERVISOR', name: '반장', description: '반 책임자', permissions: ['view', 'start', 'progress', 'complete', 'assign', 'pause', 'cancel', 'approve'] },
    ],

    // 작업자 화면 필드 정의
    masterFields: [
      { id: 1, fieldKey: 'workOrderNo', fieldName: '작업지시번호', inputType: 'display', description: '현재 작업지시' },
      { id: 2, fieldKey: 'processName', fieldName: '공정명', inputType: 'display', description: '현재 공정' },
      { id: 3, fieldKey: 'currentStep', fieldName: '현재단계', inputType: 'display', description: '진행중인 세부단계' },
      { id: 4, fieldKey: 'siteName', fieldName: '현장명', inputType: 'display', description: '작업 현장' },
      { id: 5, fieldKey: 'productName', fieldName: '제품명', inputType: 'display', description: '생산 제품' },
      { id: 6, fieldKey: 'specification', fieldName: '규격', inputType: 'display', description: '제품 규격' },
      { id: 7, fieldKey: 'targetQty', fieldName: '목표수량', inputType: 'display', description: '지시 수량' },
      { id: 8, fieldKey: 'completedQty', fieldName: '완료수량', inputType: 'number', isRequired: true, description: '현재 완료 수량' },
      { id: 9, fieldKey: 'defectQty', fieldName: '불량수량', inputType: 'number', isRequired: false, description: '불량 발생 수량' },
      { id: 10, fieldKey: 'materialLotNo', fieldName: '자재LOT', inputType: 'scan', description: '투입 자재 LOT (바코드 스캔)' },
      { id: 11, fieldKey: 'note', fieldName: '작업메모', inputType: 'textarea', description: '작업 특이사항' },
    ],

    // 작업자 화면 섹션 정의
    masterSections: [
      { id: 1, sectionKey: 'currentWork', sectionName: '현재작업', sortOrder: 1, description: '진행중인 작업 정보', fields: [1, 2, 3, 4, 5, 6] },
      { id: 2, sectionKey: 'progressInput', sectionName: '실적입력', sortOrder: 2, description: '작업 실적 입력', fields: [7, 8, 9, 10] },
      { id: 3, sectionKey: 'stepProgress', sectionName: '단계별진행', sortOrder: 3, description: '세부단계 체크리스트' },
      { id: 4, sectionKey: 'memo', sectionName: '메모', sortOrder: 4, description: '작업 메모', fields: [11] },
    ],

    // 액션 버튼 정의
    actionButtons: [
      { id: 1, actionCode: 'START', actionName: '작업시작', icon: 'Play', color: 'green', requiredRole: ['OPERATOR', 'LEAD', 'SUPERVISOR'] },
      { id: 2, actionCode: 'PAUSE', actionName: '일시중단', icon: 'Pause', color: 'yellow', requiredRole: ['LEAD', 'SUPERVISOR'] },
      { id: 3, actionCode: 'RESUME', actionName: '재개', icon: 'Play', color: 'blue', requiredRole: ['OPERATOR', 'LEAD', 'SUPERVISOR'] },
      { id: 4, actionCode: 'COMPLETE', actionName: '완료', icon: 'Check', color: 'emerald', requiredRole: ['OPERATOR', 'LEAD', 'SUPERVISOR'] },
      { id: 5, actionCode: 'DEFECT', actionName: '불량등록', icon: 'AlertTriangle', color: 'red', requiredRole: ['OPERATOR', 'LEAD', 'SUPERVISOR'] },
      { id: 6, actionCode: 'SCAN', actionName: '바코드스캔', icon: 'Scan', color: 'purple', requiredRole: ['OPERATOR', 'LEAD', 'SUPERVISOR'] },
    ],

    // 페이지 템플릿
    pageTemplates: [
      {
        id: 1,
        pageCode: 'worker_main',
        pageName: '작업자 메인',
        pagePath: '/생산관리/작업자_화면',
        pageType: 'dashboard',
        sections: [
          { sectionKey: 'myTasks', sectionName: '내 작업목록', sortOrder: 1 },
          { sectionKey: 'currentWork', sectionName: '현재작업', sortOrder: 2 },
          { sectionKey: 'progressInput', sectionName: '실적입력', sortOrder: 3 },
          { sectionKey: 'stepProgress', sectionName: '단계별진행', sortOrder: 4 },
        ],
      },
    ],
  },

  // ============ 3. 설비 기준관리 ============
  equipmentMaster: {
    id: 'equipment-master',
    title: '설비 기준관리',
    description: '생산 설비/장비 정보를 관리합니다',
    icon: 'Cog',
    tabs: [
      { id: 'list', label: '설비목록', icon: 'List' },
      { id: 'category', label: '설비분류', icon: 'Folder' },
      { id: 'maintenance', label: '점검기준', icon: 'Wrench' },
    ],

    // 설비 분류
    equipmentCategories: [
      { id: 1, code: 'CUT', name: '절단설비', description: '절단 관련 설비', sortOrder: 1 },
      { id: 2, code: 'FORM', name: '성형설비', description: '포밍/절곡 설비', sortOrder: 2 },
      { id: 3, code: 'SEW', name: '봉제설비', description: '미싱/봉제 설비', sortOrder: 3 },
      { id: 4, code: 'PACK', name: '포장설비', description: '포장 관련 설비', sortOrder: 4 },
      { id: 5, code: 'QC', name: '검사장비', description: '품질검사 장비', sortOrder: 5 },
      { id: 6, code: 'UTIL', name: '유틸리티', description: '공조/유틸리티', sortOrder: 6 },
    ],

    // 설비 상태
    equipmentStatuses: [
      { id: 1, code: 'NORMAL', name: '정상', color: 'green' },
      { id: 2, code: 'MAINTENANCE', name: '점검중', color: 'yellow' },
      { id: 3, code: 'REPAIR', name: '수리중', color: 'orange' },
      { id: 4, code: 'STOPPED', name: '가동중지', color: 'red' },
      { id: 5, code: 'IDLE', name: '대기', color: 'gray' },
    ],

    // 설비 필드 정의
    masterFields: [
      { id: 1, fieldKey: 'equipmentCode', fieldName: '설비코드', inputType: 'text', isRequired: true, description: '설비 고유 코드' },
      { id: 2, fieldKey: 'equipmentName', fieldName: '설비명', inputType: 'text', isRequired: true, description: '설비 이름' },
      { id: 3, fieldKey: 'category', fieldName: '설비분류', inputType: 'select', isRequired: true, description: '설비 분류' },
      { id: 4, fieldKey: 'processCode', fieldName: '연결공정', inputType: 'reference', isRequired: false, refType: 'process', description: '연결된 공정' },
      { id: 5, fieldKey: 'location', fieldName: '설치위치', inputType: 'text', isRequired: true, description: '설비 설치 위치' },
      { id: 6, fieldKey: 'manufacturer', fieldName: '제조사', inputType: 'text', isRequired: false, description: '설비 제조사' },
      { id: 7, fieldKey: 'model', fieldName: '모델명', inputType: 'text', isRequired: false, description: '설비 모델' },
      { id: 8, fieldKey: 'serialNo', fieldName: '시리얼번호', inputType: 'text', isRequired: false, description: '설비 시리얼' },
      { id: 9, fieldKey: 'purchaseDate', fieldName: '구매일', inputType: 'date', isRequired: false, description: '설비 구매일' },
      { id: 10, fieldKey: 'installDate', fieldName: '설치일', inputType: 'date', isRequired: false, description: '설비 설치일' },
      { id: 11, fieldKey: 'lastMaintenanceDate', fieldName: '최근점검일', inputType: 'date', isRequired: false, readOnly: true, description: '최근 점검일' },
      { id: 12, fieldKey: 'nextMaintenanceDate', fieldName: '차기점검일', inputType: 'date', isRequired: false, description: '다음 점검 예정일' },
      { id: 13, fieldKey: 'status', fieldName: '상태', inputType: 'select', isRequired: true, description: '설비 상태' },
      { id: 14, fieldKey: 'note', fieldName: '비고', inputType: 'textarea', isRequired: false, description: '특이사항' },
    ],

    // 설비 섹션 정의
    masterSections: [
      { id: 1, sectionKey: 'basicInfo', sectionName: '기본정보', sortOrder: 1, fields: [1, 2, 3, 4, 5] },
      { id: 2, sectionKey: 'specInfo', sectionName: '사양정보', sortOrder: 2, fields: [6, 7, 8, 9, 10] },
      { id: 3, sectionKey: 'maintenanceInfo', sectionName: '점검정보', sortOrder: 3, fields: [11, 12, 13, 14] },
    ],

    // 샘플 설비 데이터
    sampleEquipments: [
      { id: 1, equipmentCode: 'EQ-CUT-001', equipmentName: '스크린 절단기', category: 'CUT', processCode: 'SCR-001', location: '1공장 A라인', manufacturer: '삼성기계', model: 'SC-2000', status: '정상', installDate: '2023-01-15' },
      { id: 2, equipmentCode: 'EQ-CUT-002', equipmentName: '코일 절단기', category: 'CUT', processCode: 'SLT-001', location: '1공장 B라인', manufacturer: '대한기계', model: 'CC-1500', status: '정상', installDate: '2023-03-20' },
      { id: 3, equipmentCode: 'EQ-SEW-001', equipmentName: '공업용 미싱기', category: 'SEW', processCode: 'SCR-001', location: '1공장 A라인', manufacturer: '브라더', model: 'BS-4500', status: '정상', installDate: '2023-01-15' },
      { id: 4, equipmentCode: 'EQ-FORM-001', equipmentName: '프레스 브레이크', category: 'FORM', processCode: 'FLD-001', location: '2공장 C라인', manufacturer: '아마다', model: 'PB-3000', status: '정상', installDate: '2022-06-10' },
      { id: 5, equipmentCode: 'EQ-FORM-002', equipmentName: 'V컷팅기', category: 'FORM', processCode: 'FLD-001', location: '2공장 C라인', manufacturer: '진우기계', model: 'VC-2500', status: '점검중', installDate: '2023-02-28' },
      { id: 6, equipmentCode: 'EQ-PACK-001', equipmentName: '자동포장기', category: 'PACK', processCode: 'PKG-001', location: '3공장', manufacturer: '한국포장', model: 'AP-500', status: '정상', installDate: '2023-05-15' },
    ],
  },

  // ============ 4. 라인/작업장 기준관리 ============
  workLineMaster: {
    id: 'work-line-master',
    title: '라인/작업장 기준관리',
    description: '생산 라인 및 작업장 정보를 관리합니다',
    icon: 'GitBranch',
    tabs: [
      { id: 'factory', label: '공장', icon: 'Building' },
      { id: 'line', label: '라인', icon: 'GitBranch' },
      { id: 'station', label: '작업장', icon: 'MapPin' },
    ],

    // 공장 정의
    factories: [
      { id: 1, code: 'F1', name: '1공장', address: '경기도 화성시', description: '스크린/슬랫 생산', isActive: true },
      { id: 2, code: 'F2', name: '2공장', address: '경기도 화성시', description: '절곡 생산', isActive: true },
      { id: 3, code: 'F3', name: '3공장', address: '경기도 화성시', description: '포장/출하', isActive: true },
    ],

    // 생산라인 정의
    productionLines: [
      { id: 1, code: 'LINE-A', name: 'A라인', factoryId: 1, processType: 'SCREEN', capacity: 100, description: '스크린 메인라인', isActive: true },
      { id: 2, code: 'LINE-B', name: 'B라인', factoryId: 1, processType: 'SLAT', capacity: 150, description: '슬랫 메인라인', isActive: true },
      { id: 3, code: 'LINE-C', name: 'C라인', factoryId: 2, processType: 'FOLD', capacity: 80, description: '절곡 메인라인', isActive: true },
      { id: 4, code: 'LINE-D', name: 'D라인', factoryId: 2, processType: 'STOCK', capacity: 60, description: '포밍/재고라인', isActive: true },
      { id: 5, code: 'LINE-P', name: 'P라인', factoryId: 3, processType: 'PACK', capacity: 200, description: '포장라인', isActive: true },
    ],

    // 작업장/스테이션 정의
    workStations: [
      { id: 1, code: 'WS-A01', name: '스크린 자재투입', lineId: 1, stepCode: 'SCR-MAT', equipmentIds: [], workerCount: 1 },
      { id: 2, code: 'WS-A02', name: '스크린 절단', lineId: 1, stepCode: 'SCR-CUT', equipmentIds: [1], workerCount: 1 },
      { id: 3, code: 'WS-A03', name: '스크린 미싱', lineId: 1, stepCode: 'SCR-SEW', equipmentIds: [3], workerCount: 2 },
      { id: 4, code: 'WS-A04', name: '스크린 앤드락', lineId: 1, stepCode: 'SCR-END', equipmentIds: [], workerCount: 1 },
      { id: 5, code: 'WS-B01', name: '슬랫 절단', lineId: 2, stepCode: 'SLT-CUT', equipmentIds: [2], workerCount: 1 },
      { id: 6, code: 'WS-B02', name: '슬랫 미미작업', lineId: 2, stepCode: 'SLT-FIN', equipmentIds: [], workerCount: 2 },
      { id: 7, code: 'WS-C01', name: '절곡 절단', lineId: 3, stepCode: 'FLD-CUT', equipmentIds: [], workerCount: 1 },
      { id: 8, code: 'WS-C02', name: 'V컷팅', lineId: 3, stepCode: 'FLD-VCUT', equipmentIds: [5], workerCount: 1 },
      { id: 9, code: 'WS-C03', name: '절곡', lineId: 3, stepCode: 'FLD-BEND', equipmentIds: [4], workerCount: 1 },
    ],

    // 라인 필드 정의
    lineFields: [
      { id: 1, fieldKey: 'lineCode', fieldName: '라인코드', inputType: 'text', isRequired: true },
      { id: 2, fieldKey: 'lineName', fieldName: '라인명', inputType: 'text', isRequired: true },
      { id: 3, fieldKey: 'factoryId', fieldName: '공장', inputType: 'select', isRequired: true },
      { id: 4, fieldKey: 'processType', fieldName: '공정유형', inputType: 'select', isRequired: true },
      { id: 5, fieldKey: 'capacity', fieldName: '일생산능력', inputType: 'number', isRequired: true },
      { id: 6, fieldKey: 'description', fieldName: '설명', inputType: 'textarea', isRequired: false },
      { id: 7, fieldKey: 'isActive', fieldName: '사용여부', inputType: 'checkbox', isRequired: false },
    ],
  },

  // ============ 5. BOM 기준관리 ============
  bomMaster: {
    id: 'bom-master',
    title: 'BOM 기준관리',
    description: '자재명세서(Bill of Materials)를 관리합니다',
    icon: 'Layers',
    tabs: [
      { id: 'product', label: '제품별 BOM', icon: 'Package' },
      { id: 'material', label: '자재목록', icon: 'List' },
      { id: 'calculation', label: '소요량계산', icon: 'Calculator' },
    ],

    // BOM 유형
    bomTypes: [
      { id: 1, code: 'PRODUCT', name: '완제품', description: '최종 출하 제품', sortOrder: 1 },
      { id: 2, code: 'SEMI', name: '반제품', description: '중간 조립품', sortOrder: 2 },
      { id: 3, code: 'PART', name: '부품', description: '단위 부품', sortOrder: 3 },
    ],

    // 자재 분류
    materialCategories: [
      { id: 1, code: 'RAW', name: '원자재', description: '철판, 코일, 원단 등' },
      { id: 2, code: 'SUB', name: '부자재', description: '볼트, 너트, 라벨 등' },
      { id: 3, code: 'PACK', name: '포장재', description: '박스, 테이프, 완충재 등' },
      { id: 4, code: 'SEMI', name: '반제품', description: '중간 조립품' },
    ],

    // BOM 필드 정의
    masterFields: [
      { id: 1, fieldKey: 'bomCode', fieldName: 'BOM코드', inputType: 'text', isRequired: true },
      { id: 2, fieldKey: 'productCode', fieldName: '제품코드', inputType: 'reference', isRequired: true, refType: 'item' },
      { id: 3, fieldKey: 'productName', fieldName: '제품명', inputType: 'text', isRequired: true },
      { id: 4, fieldKey: 'bomType', fieldName: 'BOM유형', inputType: 'select', isRequired: true },
      { id: 5, fieldKey: 'version', fieldName: '버전', inputType: 'text', isRequired: true },
      { id: 6, fieldKey: 'effectiveDate', fieldName: '적용시작일', inputType: 'date', isRequired: true },
      { id: 7, fieldKey: 'expiryDate', fieldName: '적용종료일', inputType: 'date', isRequired: false },
      { id: 8, fieldKey: 'isActive', fieldName: '사용여부', inputType: 'checkbox', isRequired: false },
    ],

    // BOM 상세 항목 필드
    bomDetailFields: [
      { id: 1, fieldKey: 'materialCode', fieldName: '자재코드', inputType: 'reference', isRequired: true, refType: 'item' },
      { id: 2, fieldKey: 'materialName', fieldName: '자재명', inputType: 'text', isRequired: true },
      { id: 3, fieldKey: 'materialCategory', fieldName: '자재분류', inputType: 'select', isRequired: true },
      { id: 4, fieldKey: 'unit', fieldName: '단위', inputType: 'select', isRequired: true, options: { items: ['EA', 'M', 'KG', 'ROLL', 'SET'] } },
      { id: 5, fieldKey: 'requiredQty', fieldName: '소요량', inputType: 'number', isRequired: true },
      { id: 6, fieldKey: 'lossRate', fieldName: '로스율(%)', inputType: 'number', isRequired: false, defaultValue: 0 },
      { id: 7, fieldKey: 'calculatedQty', fieldName: '실소요량', inputType: 'number', readOnly: true, description: '소요량 × (1 + 로스율/100)' },
      { id: 8, fieldKey: 'note', fieldName: '비고', inputType: 'textarea', isRequired: false },
    ],

    // 제품별 BOM 샘플 데이터
    sampleBoms: [
      {
        id: 1,
        bomCode: 'BOM-SH3040',
        productCode: 'SH3040',
        productName: '방화셔터 3000×4000',
        bomType: 'PRODUCT',
        version: '1.0',
        effectiveDate: '2024-01-01',
        isActive: true,
        details: [
          { materialCode: 'SCR-0.3T', materialName: '스크린 원단 0.3T', materialCategory: 'RAW', unit: 'M', requiredQty: 12.5, lossRate: 5 },
          { materialCode: 'SLT-0.5T', materialName: '슬랫 코일 0.5T', materialCategory: 'RAW', unit: 'KG', requiredQty: 25, lossRate: 3 },
          { materialCode: 'FLD-1.2T', materialName: '절곡판 1.2T', materialCategory: 'RAW', unit: 'KG', requiredQty: 15, lossRate: 5 },
          { materialCode: 'ENDLOCK', materialName: '앤드락', materialCategory: 'SUB', unit: 'EA', requiredQty: 2, lossRate: 0 },
          { materialCode: 'BOLT-M8', materialName: '볼트 M8×20', materialCategory: 'SUB', unit: 'EA', requiredQty: 24, lossRate: 2 },
          { materialCode: 'BOX-L', materialName: '포장박스 (대)', materialCategory: 'PACK', unit: 'EA', requiredQty: 1, lossRate: 0 },
        ],
      },
    ],
  },
};

export default productionMasterConfig;
