/* ============================================
   items.css — 품목 관리 전용 스타일
   원본: mia items.html에서 페이지 전용 추출
   ============================================ */

/* items 페이지: main의 스크롤을 막고 items-layout이 뷰포트를 채움 */
main:has(.items-layout) {
  overflow: hidden !important;
  /* main이 flex-1이므로 남은 공간 전부 사용하게 height 보장 */
  height: 0;
  min-height: 0;
}

/* --- 3컬럼 레이아웃 (카테고리 + 테이블 + 상세) --- */
.items-layout {
  display: flex;
  height: 100%;
  gap: 0;
  overflow: hidden;
  /* 테이블이 전체 너비를 채우도록 */
  width: 100%;
}

/* --- 좌측 카테고리 트리 패널 (220px) --- */
.cat-panel {
  width: 220px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--tint);
  display: flex;
  flex-direction: column;
  border-radius: 12px 0 0 12px;
  overflow: hidden;
}

.cat-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cat-header-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--brand);
}

.cat-header-count {
  font-size: 0.6875rem;
  color: var(--light);
}

/* 카테고리 그룹 라벨 (도어/자재) */
.cat-group-label {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--light);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 12px 4px;
}

/* 카테고리 항목 */
.cat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--secondary);
  border-radius: 6px;
  margin: 1px 4px;
  transition: all 0.15s ease;
}

.cat-item:hover {
  background: var(--bg-light);
}

.cat-item.active {
  background: rgba(59, 130, 246, 0.08);
  color: #3B82F6;
  font-weight: 600;
}

.cat-item .count {
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--light);
  background: var(--bg-light);
  padding: 1px 6px;
  border-radius: 10px;
}

.cat-item.active .count {
  background: rgba(59, 130, 246, 0.1);
  color: #3B82F6;
}

/* 건수 0인 카테고리 — 비활성 스타일 */
.cat-item-empty {
  opacity: 0.45;
}

/* 카테고리 토글 화살표 */
.cat-toggle {
  width: 14px;
  font-size: 0.5625rem;
  color: var(--light);
  text-align: center;
  transition: transform 0.2s;
}

/* 카테고리 자식 (기본 숨김) */
.cat-children {
  display: none;
  padding-left: 8px;
}

.cat-children.open {
  display: block;
}

/* --- 중앙 테이블 영역 — flex:1로 남은 공간 전부 채움 --- */
.items-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--background);
}

/* 툴바 */
.items-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: white;
  border-bottom: 1px solid var(--tint);
}

.items-toolbar-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--brand);
}

.items-toolbar-count {
  font-size: 0.75rem;
  color: var(--light);
}

/* 유형 필터 버튼 */
.item-type-btn {
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  border: 1px solid var(--tint);
  border-radius: 20px;
  background: white;
  color: var(--tertiary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.item-type-btn.active {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

/* 검색 입력 */
.items-search {
  width: 200px;
  border: 1px solid var(--tint);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.75rem;
  color: var(--brand);
  outline: none;
  font-family: inherit;
}

.items-search:focus {
  border-color: #3B82F6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* 신규 버튼 */
.btn-new-item {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  background: var(--secondary);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-new-item:hover {
  background: var(--brand);
}

/* 테이블 래퍼 — Tabulator가 남은 높이 전부 사용 */
.items-table-wrap {
  flex: 1;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

/* 테이블 — 컬럼 너비 고정 */
.items-data-table {
  position: relative;
  table-layout: fixed;
  width: 100%;
}

/* 컬럼 너비 (스크린샷 기준 9컬럼 비율) */
.items-data-table th:nth-child(1),
.items-data-table td:nth-child(1) { width: 13%; }  /* 코드 */
.items-data-table th:nth-child(2),
.items-data-table td:nth-child(2) { width: 18%; }  /* 품명 */
.items-data-table th:nth-child(3),
.items-data-table td:nth-child(3) { width: 6%; text-align: center; }  /* 유형 */
.items-data-table th:nth-child(4),
.items-data-table td:nth-child(4) { width: 11%; }  /* 카테고리 */
.items-data-table th:nth-child(5),
.items-data-table td:nth-child(5) { width: 8%; text-align: center; }  /* 바규격 */
.items-data-table th:nth-child(6),
.items-data-table td:nth-child(6) { width: 8%; text-align: center; }  /* 리비전 */
.items-data-table th:nth-child(7),
.items-data-table td:nth-child(7) { width: 7%; text-align: center; }  /* 단위 */
.items-data-table th:nth-child(8),
.items-data-table td:nth-child(8) { width: 12%; text-align: right; padding-right: 16px; }  /* 단가 */
.items-data-table th:nth-child(9),
.items-data-table td:nth-child(9) { width: 6%; text-align: center; }  /* 상태 */

/* 긴 텍스트 말줄임 */
.items-data-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- 유형 뱃지 --- */
.type-product {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.625rem;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.1);
  color: #15803D;
}

.type-material {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.625rem;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.1);
  color: #6D28D9;
}

.type-semi {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.625rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.1);
  color: #B45309;
}

/* --- 우측 상세 패널 (380px 슬라이드) --- */
.items-detail-panel {
  width: 0;
  flex-shrink: 0;
  background: white;
  border-left: 1px solid var(--tint);
  overflow: hidden;
  transition: width 0.25s ease;
  display: flex;
  flex-direction: column;
  border-radius: 0 12px 12px 0;
}

.items-detail-panel.open {
  width: 380px;
}

.item-detail-field {
  margin-bottom: 12px;
}

.item-detail-label {
  font-size: 0.6875rem;
  color: var(--light);
  margin-bottom: 2px;
}

.item-detail-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--brand);
}

/* 마감재/옵션 태그 */
.attr-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--bg-light);
  color: var(--secondary);
  margin: 2px 2px;
}

/* 상세 패널 버튼 */
.btn-edit-item {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--tint);
  border-radius: 6px;
  background: white;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  font-family: inherit;
}

.btn-edit-item:hover {
  background: var(--bg-light);
}

.btn-revision {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 6px;
  background: var(--secondary);
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  font-family: inherit;
}

.btn-revision:hover {
  background: var(--brand);
}

/* --- 데이터 테이블 (Tabulator 미사용 시 폴백) --- */
.items-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.items-data-table thead {
  background: var(--background);
  border-bottom: 1px solid var(--tint);
}

.items-data-table thead th {
  position: sticky;
  top: 0;
  background: var(--background);
  z-index: 2;
}

.items-data-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--tertiary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.items-data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--tint);
  color: var(--brand);
}

.items-data-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.items-data-table tbody tr:hover {
  background: var(--bg-light);
}

.items-data-table tbody tr.selected {
  background: rgba(59, 130, 246, 0.06);
}

/* 코드 컬럼 모노스페이스 */
.item-code {
  font-weight: 600;
  color: var(--secondary);
  font-size: 0.75rem;
}

/* 단가 컬럼 */
.item-price {
  font-weight: 500;
  text-align: right;
}

/* 상태 컬럼 */
.item-status-active {
  color: #15803D;
  font-weight: 600;
  font-size: 0.75rem;
}

.item-status-inactive {
  color: #DC2626;
  font-weight: 600;
  font-size: 0.75rem;
}

/* 리비전 뱃지 */
.rev-badge {
  font-size: 0.75rem;
  background: var(--bg-light);
  padding: 1px 6px;
  border-radius: 4px;
}

.rev-badge.rev-current {
  background: rgba(34, 197, 94, 0.1);
  color: #15803D;
  font-weight: 600;
}

/* --- 상세 패널 헤더 --- */
.detail-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.detail-panel-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand);
}

.detail-close-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--light);
  font-size: 1rem;
}

.detail-close-btn:hover {
  color: var(--brand);
}

/* 상세 패널 섹션 제목 */
.item-detail-section-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--brand);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-light);
}

/* --- 비활성화 버튼 --- */
.btn-deactivate {
  flex: 1;
  padding: 8px 0;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  background: white;
  font-size: 0.75rem;
  font-weight: 600;
  color: #DC2626;
  cursor: pointer;
  font-family: inherit;
}

.btn-deactivate:hover {
  background: rgba(239, 68, 68, 0.05);
}

/* --- 모달 (등록/수정) --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  max-width: 90vw;
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--light);
  font-size: 1.125rem;
}

.modal-close:hover {
  color: var(--brand);
}

.modal-body {
  padding: 24px;
}

.modal-field {
  margin-bottom: 16px;
}

.modal-field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tertiary);
  margin-bottom: 6px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--tint);
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--brand);
  background: #fff;
}

.modal-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(44, 51, 68, 0.08);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--tint);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
}

.modal-btn-cancel {
  background: var(--bg-light);
  color: var(--tertiary);
  border: 1px solid var(--tint);
}

.modal-btn-cancel:hover {
  background: var(--tint);
}

.modal-btn-confirm {
  background: var(--brand);
  color: #fff;
}

.modal-btn-confirm:hover {
  background: var(--secondary);
}

/* --- 페이지네이션 (스펙 10) --- */
.items-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid var(--tint);
}

.page-link {
  padding: 6px 14px;
  border: 1px solid var(--tint);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
  transition: all 0.2s;
}

.page-link:hover {
  background: var(--bg-light);
}

.page-info {
  font-size: 0.8125rem;
  color: var(--tertiary);
  font-weight: 600;
}

/* --- 엑셀 드롭존 (품목 대량 이관) --- */
.excel-dropzone {
  padding: 2rem;
  border: 2px dashed var(--tint);
  border-radius: 12px;
  background: var(--bg-light);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.excel-dropzone:hover {
  border-color: #15803D;
  background: rgba(34, 197, 94, 0.03);
}

/* --- 상세 패널 탭 (기본정보 / BOM) --- */
.item-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--tint);
  margin-bottom: 16px;
}

.item-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--light);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.item-tab:hover {
  color: var(--secondary);
}

.item-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.item-tab-content {
  /* 탭 컨텐츠 — display 토글로 전환 */
}

/* --- BOM 구성 스타일 (스펙 10.1) --- */
/* 슬롯 헤더 (상바/하바/좌세로바 등) */
.item-bom-slot-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0 4px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--brand);
  border-bottom: 1px solid var(--bg-light);
  margin-top: 8px;
}

.item-bom-slot-count {
  font-size: 0.625rem;
  background: var(--bg-light);
  color: var(--light);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

/* 부품 목록 */
.item-bom-parts {
  padding-left: 4px;
}

.item-bom-part-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--bg-light);
}

.item-bom-part-code {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--secondary);
  font-size: 0.6875rem;
  min-width: 80px;
}

.item-bom-part-name {
  flex: 1;
  color: var(--brand);
}

.item-bom-part-qty {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: var(--tertiary);
  font-size: 0.6875rem;
}

/* --- 카테고리 관리 버튼 --- */
.cat-manage-btn {
  width: 22px;
  height: 22px;
  border: 1px solid var(--tint);
  border-radius: 4px;
  background: white;
  color: var(--light);
  font-size: 0.625rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.cat-manage-btn:hover {
  background: var(--bg-light);
  color: var(--brand);
}

/* --- 카테고리 관리 모달 — 목록 항목 --- */
.cat-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--bg-light);
  transition: background 0.15s;
}

.cat-list-item:hover {
  background: var(--bg-light);
}

.cat-list-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--brand);
}

.cat-list-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.cat-list-item:hover .cat-list-actions {
  opacity: 1;
}

.cat-list-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--tint);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  transition: all 0.15s;
}

.cat-list-btn-edit {
  color: var(--secondary);
}

.cat-list-btn-edit:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: #3B82F6;
}

.cat-list-btn-delete {
  color: #DC2626;
}

.cat-list-btn-delete:hover {
  background: rgba(239, 68, 68, 0.05);
  border-color: #DC2626;
}

/* --- Tabulator 테이블 커스텀 — items 화면 전용 오버라이드 --- */
/* Tabulator 기본 스타일을 items 화면에 맞게 조정 */
/* 테이블이 래퍼 높이 전부를 채우도록 height:100% */
.items-table-wrap .tabulator {
  border: none;
  font-size: 0.8125rem;
  background: transparent;
  height: 100% !important;
}

.items-table-wrap .tabulator .tabulator-header {
  background: var(--background);
  border-bottom: 1px solid var(--tint);
}

.items-table-wrap .tabulator .tabulator-header .tabulator-col {
  background: var(--background);
  border-right: 1px solid var(--tint);
}

.items-table-wrap .tabulator .tabulator-header .tabulator-col .tabulator-col-content {
  padding: 10px 12px;
}

.items-table-wrap .tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  font-weight: 600;
  color: var(--tertiary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.items-table-wrap .tabulator .tabulator-tableholder .tabulator-table .tabulator-row {
  cursor: pointer;
  border-bottom: 1px solid var(--tint);
}

/* 행 줄무늬 — 홀짝 배경색 (원본 mia 스타일) */
.items-table-wrap .tabulator .tabulator-tableholder .tabulator-table .tabulator-row:nth-child(even) {
  background: var(--background);
}

.items-table-wrap .tabulator .tabulator-tableholder .tabulator-table .tabulator-row:hover {
  background: var(--bg-light);
}

.items-table-wrap .tabulator .tabulator-tableholder .tabulator-table .tabulator-row .tabulator-cell {
  border-right: 1px solid var(--tint);
  padding: 8px 12px;
  color: var(--brand);
}

/* Tabulator 페이지네이션 스타일 */
.items-table-wrap .tabulator .tabulator-footer {
  background: white;
  border-top: 1px solid var(--tint);
}

.items-table-wrap .tabulator .tabulator-footer .tabulator-page {
  border: 1px solid var(--tint);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand);
}

.items-table-wrap .tabulator .tabulator-footer .tabulator-page.active {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

/* Tabulator placeholder (빈 상태) */
.items-table-wrap .tabulator .tabulator-placeholder .tabulator-placeholder-contents {
  color: var(--light);
  font-size: 0.875rem;
  font-weight: 500;
}
