/**
 * BOM — 모듈 전용.
 */

/* ─────────────────────────────────────────────
   좌측 BOM 리스트 행
   ───────────────────────────────────────────── */
.bom-item {
    display: block; width: 100%;
    padding: 10px 12px; border-radius: 10px;
    text-align: left; cursor: pointer;
    background: transparent;
    box-shadow: inset 0 0 0 1px transparent;
    transition: all var(--t-fast) var(--ease);
}
.bom-item:hover {
    background: rgb(255 255 255 / 0.03);
    box-shadow: inset 0 0 0 1px var(--border);
}
.bom-item[data-active="1"] {
    background: linear-gradient(180deg, rgb(139 149 255 / 0.10), rgb(139 149 255 / 0.04));
    box-shadow: inset 0 0 0 1px var(--border-brand);
}
.bom-item[data-active="1"] .text-ink-100 { color: var(--brand-light); }

/* ─────────────────────────────────────────────
   탭
   ───────────────────────────────────────────── */
.bom-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    border-bottom: 1px solid rgb(255 255 255 / 0.06);
    background: rgb(255 255 255 / 0.012);
}
.bom-tab {
    position: relative;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-400);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: color var(--t-fast) var(--ease);
}
.bom-tab:hover { color: var(--ink-200); }
.bom-tab[data-active="1"] {
    color: var(--brand-light);
}
.bom-tab[data-active="1"]::after {
    content: '';
    position: absolute;
    left: 8px; right: 8px; bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--brand), var(--brand-light));
    border-radius: 2px;
}

/* ─────────────────────────────────────────────
   컴포넌트 테이블 — 압축 행 + sticky 헤더
   ───────────────────────────────────────────── */
#componentTable thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 36px;
    padding-left: 12px;
    padding-right: 12px;
}
#componentTable tbody td {
    border-bottom: 1px solid rgb(255 255 255 / 0.04);
    height: auto;
    padding: 6px 12px;
}
#componentTable .bom-actions { white-space: nowrap; }
#componentTable .bom-actions .btn-xs { padding: 3px 5px; }

/* 트리 토글 (셰브런) */
.bom-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    margin-right: 2px;
    border: 0; border-radius: 5px;
    background: transparent;
    color: var(--ink-400);
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.bom-tree-toggle:hover { background: rgb(139 149 255 / 0.14); color: var(--brand-light); }
.bom-tree-toggle i { transition: transform 0.15s var(--ease); }
.bom-tree-toggle[data-open="1"] i { transform: rotate(90deg); }
.bom-tree-toggle--spacer { visibility: hidden; cursor: default; }

/* 품목명 한 줄 라인 — 이름 + (규격·사양·제조사) + 접힘 배지 */
.bom-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}
.bom-child-sub {
    color: rgb(255 255 255 / 0.72);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 0;
}
.bom-child-mfr { color: var(--ink-600, #6b7080); }

/* 접힌 반제품 — 하위 요약 배지 */
.bom-collapse-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid rgb(91 154 255 / 0.25);
    background: rgb(91 154 255 / 0.10);
    color: rgb(150 190 255);
    font-size: 11px;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--t-fast) var(--ease);
}
.bom-collapse-badge:hover {
    background: rgb(91 154 255 / 0.18);
    border-color: rgb(91 154 255 / 0.45);
}

/* 트리 툴바 (검색 · 펼치기/접기 · 카운트) */
.bom-treebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid rgb(255 255 255 / 0.06);
    background: rgb(255 255 255 / 0.015);
    flex-wrap: wrap;
}
.bom-treebar__search { width: 240px; max-width: 100%; }

/* 전개도 테이블 — 압축 + sticky */
#tabExplode .table-std thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 36px;
}
#tabExplode .table-std tbody td {
    height: auto;
    padding-top: 6px;
    padding-bottom: 6px;
}

/* 데스크톱 워크스페이스 — 상세 카드를 화면 높이에 고정, 트리·전개도는 내부 스크롤
   (모바일은 기존 페이지 스크롤 유지) */
@media (min-width: 1024px) {
    #bomDetail {
        display: flex;
        flex-direction: column;
        max-height: calc(100vh - 140px);
    }
    #detailPane {
        height: auto;
        flex: 1 1 auto;
        min-height: 0;
    }
    #treePane { overflow: auto; }
    #tabExplode > .overflow-x-auto { overflow: auto; }
}

/* 락 행 — SEMI 의 손자 */
.bom-row--locked td {
    background: rgb(255 255 255 / 0.012);
}
.bom-row--locked:hover td {
    background: rgb(255 255 255 / 0.02);
}

/* 트리 가지 */
.bom-branch {
    display: inline-block;
    position: relative;
    height: 18px;
    flex-shrink: 0;
}
.bom-branch__line {
    position: absolute;
    right: 8px; top: 50%;
    width: 12px; height: 1px;
    background: rgb(255 255 255 / 0.18);
}
.bom-branch__line::before {
    content: '';
    position: absolute;
    right: 12px; top: -10px;
    width: 1px; height: 11px;
    background: rgb(255 255 255 / 0.18);
}

/* ─────────────────────────────────────────────
   드롭존 (트리 영역)
   ───────────────────────────────────────────── */
#treePane {
    position: relative;
    transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
#treePane.is-dragover {
    background: rgb(139 149 255 / 0.06);
    box-shadow: inset 0 0 0 2px var(--brand);
}
#treePane.is-dragover::before {
    content: '\f063\00a0\00a0여기에 떨어뜨려서 추가';
    font-family: 'Font Awesome 6 Free', var(--kr);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: var(--brand-light);
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0.02em;
    background: rgb(11 14 22 / 0.55);
    z-index: 10;
}

/* ─────────────────────────────────────────────
   자재 팔레트 (오른쪽)
   ───────────────────────────────────────────── */
.bom-palette {
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgb(255 255 255 / 0.06);
    background: rgb(255 255 255 / 0.012);
    min-height: 0;
}
.bom-palette__head {
    padding: 12px 14px;
    border-bottom: 1px solid rgb(255 255 255 / 0.06);
    background: rgb(255 255 255 / 0.012);
}
.bom-palette__list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    margin: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 카드 */
.bom-card {
    padding: 8px 10px;
    border-radius: 8px;
    background: rgb(255 255 255 / 0.025);
    border: 1px solid rgb(255 255 255 / 0.05);
    cursor: grab;
    user-select: none;
    transition: all var(--t-fast) var(--ease);
}
.bom-card:hover {
    background: rgb(139 149 255 / 0.08);
    border-color: var(--border-brand);
    transform: translateX(-2px);
}
.bom-card:active {
    cursor: grabbing;
    transform: scale(0.98);
}
.bom-card.is-dragging {
    opacity: 0.4;
    transform: scale(0.96);
}
.bom-card.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.bom-card.is-disabled:hover {
    transform: none;
    background: rgb(255 255 255 / 0.025);
    border-color: rgb(255 255 255 / 0.05);
}
.bom-card.is-pulsing {
    animation: bom-pulse 350ms var(--ease);
}
@keyframes bom-pulse {
    0%   { box-shadow: 0 0 0 0   rgb(139 149 255 / 0.7); }
    100% { box-shadow: 0 0 0 14px rgb(139 149 255 / 0); }
}

/* 핀 필터 */
.bom-pill {
    padding: 3px 9px;
    font-size: 11px;
    border-radius: 999px;
    background: transparent;
    border: 1px solid rgb(255 255 255 / 0.10);
    color: var(--ink-400);
    cursor: pointer;
    transition: all var(--t-fast) var(--ease);
}
.bom-pill:hover {
    border-color: var(--border-brand);
    color: var(--ink-200);
}
.bom-pill[data-active="1"] {
    background: linear-gradient(180deg, rgb(139 149 255 / 0.16), rgb(139 149 255 / 0.06));
    border-color: var(--border-brand);
    color: var(--brand-light);
}

/* 팔레트 카드 — 사용처 버튼 (disabled 카드에서도 클릭 가능) */
.bom-card__wu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-500);
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0;
    transition: all var(--t-fast) var(--ease);
}
.bom-card:hover .bom-card__wu { opacity: 1; }
.bom-card__wu:hover {
    background: rgb(139 149 255 / 0.12);
    border-color: var(--border-brand);
    color: var(--brand-light);
}
/* disabled 카드(pointer-events:none)에서도 사용처 버튼만 살림 */
.bom-card.is-disabled { opacity: 0.45; }
.bom-card.is-disabled .bom-card__wu {
    pointer-events: auto;
    opacity: 1;
}

/* ─────────────────────────────────────────────
   어디에 쓰이나 (Where-used) 드로어 행
   ───────────────────────────────────────────── */
.bom-wu-row {
    display: block; width: 100%;
    padding: 9px 11px; border-radius: 9px;
    text-align: left; cursor: pointer;
    background: rgb(255 255 255 / 0.02);
    border: 1px solid rgb(255 255 255 / 0.05);
    transition: all var(--t-fast) var(--ease);
}
.bom-wu-row:hover {
    background: rgb(139 149 255 / 0.08);
    border-color: var(--border-brand);
}

/* ─────────────────────────────────────────────
   전개도 — 출처 태그
   ───────────────────────────────────────────── */
.bom-source-tag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    margin: 1px 3px 1px 0;
    border-radius: 999px;
    background: rgb(255 255 255 / 0.04);
    border: 1px solid rgb(255 255 255 / 0.06);
    font-size: 11px;
    color: var(--ink-300);
    white-space: nowrap;
}

/* ── 자식 품목 셀 강조 (구성 트리) ──
   품목명: 흰색·굵게·+0.5px, 한 줄 유지. 규격·사양은 .bom-child-sub (한 줄 truncate). */
#componentTable .bom-child-name {
    color: #ffffff;
    font-weight: 700;
    font-size: calc(1em + 0.5px);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── 품목 기초자료 드로어 — 필드 카드 (card-glow 는 공통 app.css) ── */
.ii-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 10px 14px;
    min-width: 0;
}
.ii-card__label {
    font-size: 11px;
    color: var(--ink-500);
    margin-bottom: 4px;
}
.ii-card__value {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink-50);
    word-break: break-word;
}
