/* ==========================================================================
 * 입고 등록 — AI 거래명세서 인식
 * ========================================================================== */
.ai-dropzone {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 11rem;
    border: 2px dashed var(--theme-border-color);
    border-radius: 0.75rem;
    background: var(--sf-inset, var(--theme-tertiary-bg));
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}
.ai-dropzone:hover,
.ai-dropzone:focus-visible,
.ai-dropzone.is-dragover {
    border-color: var(--hospital-blue);
    background: var(--theme-primary-bg-subtle);
    outline: none;
}
.ai-dropzone-empty {
    text-align: center;
    padding: 1rem;
}
/* 카메라 아이콘 — 누를 곳이 바로 보이게 크게(3rem), 커진 만큼 선은 조금 가늘게 */
.ai-dropzone-empty svg {
    width: 3rem;
    height: 3rem;
    stroke-width: 1.75;
    color: var(--brand-emph);
}
.ai-preview {
    display: block;
    max-width: 100%;
    max-height: 22rem;
    object-fit: contain;
}
.ai-tips summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8125rem;
}
.ai-tips ul {
    padding-left: 1.1rem;
    margin: 0.5rem 0;
    font-size: 0.8125rem;
}
.ai-tips > div {
    font-size: 0.8125rem;
}
/* 촬영 예시 창의 그림(가로 스마트폰 · 명세서가 화면에 꽉 참) */
.receipt-example-image {
    display: block;
    width: 100%;
    height: auto;
}
@media (min-width: 1200px) {
    .ai-panel {
        position: sticky;
        top: calc(var(--theme-topbar-height) + 1rem);
    }
}

/* 입고 품목 표 */
.receipt-lines td {
    vertical-align: top;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}
.receipt-lines .form-control {
    min-width: 0;
}
/* 품명 검색 선택 상자를 펼친 동안에는 옆 스크롤 틀이 목록을 자르지 않게 한다. */
.table-responsive:has(.receipt-lines .choices.is-open) {
    overflow: visible;
}
.line-hint {
    min-height: 1rem;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    line-height: 1.3;
}
.receipt-total th {
    font-variant-numeric: tabular-nums;
}

/* AI 설정 — 최근 6개월 비용 막대 */
.ai-month-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 5.5rem;
}
.ai-month-bar {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    flex: 1;
    height: 100%;
}
.ai-month-fill {
    background: var(--hospital-blue);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
}
.ai-month-label {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    text-align: center;
    color: var(--theme-secondary-color);
}


/* 입고 품목 — 휴대폰(768px 미만)에서는 줄마다 카드. 표로 두면 품명 · 규격까지만 보이고 수량 · 금액은 옆으로 밀어야 했다
   (명세서를 휴대폰으로 찍어 등록하는 화면이라 자주 쓴다). 칸 이름은 td[data-label], 관리 안 하는 LOT · 유통기한은 숨긴다. */
@media screen and (max-width: 767.98px) {
    .receipt-lines thead,
    .receipt-lines .receipt-total,
    .receipt-lines [data-track-off] {
        display: none;
    }
    .receipt-lines,
    .receipt-lines tbody,
    .receipt-lines tfoot {
        display: block;
        width: 100%;
    }
    .receipt-lines tr.receipt-line {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 2.25rem;
        grid-template-areas:
            "name name remove"
            "spec spec spec"
            "lot expiry expiry"
            "qty price price"
            "supply tax tax";
        gap: 0.375rem 0.5rem;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--theme-border-color);
    }
    .receipt-lines tr.receipt-line > td {
        display: block;
        padding: 0;
        border: 0;
    }
    .receipt-lines .rl-name { grid-area: name; }
    .receipt-lines .rl-spec { grid-area: spec; }
    .receipt-lines .rl-lot { grid-area: lot; }
    .receipt-lines .rl-expiry { grid-area: expiry; }
    .receipt-lines .rl-qty { grid-area: qty; }
    .receipt-lines .rl-price { grid-area: price; }
    .receipt-lines .rl-supply { grid-area: supply; }
    .receipt-lines .rl-tax { grid-area: tax; }
    .receipt-lines .rl-remove { grid-area: remove; }
    .receipt-lines td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.125rem;
        color: var(--theme-secondary-color);
        font-size: 0.75rem;
    }
    /* 관리 안 하는 품목의 LOT · 유통기한 칸(입력이 꺼짐)은 이름째 숨긴다 */
    .receipt-lines td.rl-lot:not(:has(input:not([disabled]):not([hidden]))),
    .receipt-lines td.rl-expiry:not(:has(input:not([disabled]):not([hidden]))) {
        display: none;
    }
    .receipt-lines tfoot tr {
        display: flex;
        justify-content: flex-end;
        align-items: baseline;
        gap: 0.75rem;
        padding: 0.5rem 1rem;
    }
    .receipt-lines tfoot th {
        padding: 0;
    }
    .receipt-lines tfoot th:empty {
        display: none;
    }
}
