/* ---------------------------------------------------------------------------
   AI 서비스 관리 — 모델 관리
   2026-09-17

   메인 카드는 모델당 하나, 버전별 관리는 카드 아래 별도 목록으로 둡니다.
   기본 정보가 열 개 가까이 되는데 표로 두면 가로로 밀려 아무것도 안 읽힙니다.
   --------------------------------------------------------------------------- */

.ai-model-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 12px 0;
}
.ai-model-shortcuts a { text-decoration: underline; text-underline-offset: 3px; }
#ai-model-health, #ai-model-search { scroll-margin-top: 80px; }
.ai-list-help { margin: 8px 0 14px; }
.ai-list-help p { margin-top: 8px; }

.ai-filter {
    margin-bottom: 12px;
}

.ai-model-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.ai-model-search label { margin: 0; }
.ai-model-search input { flex: 1 1 220px; min-width: 0; max-width: 440px; }
.ai-model-search .ai-help { overflow-wrap: anywhere; }

.ai-filter .badge {
    margin-left: 4px;
    background: var(--ai-text-muted, #526579);
    color: #fff;
}

.ai-filter .active .badge {
    background: var(--ai-text-link, #21618c);
}

.ai-status {
    margin: 8px 0 14px;
    color: var(--ai-text-muted, #526579);
    font-size: 14px;
}

.ai-status.is-error {
    color: var(--ai-text-danger, #a52b35);
}

.ai-help {
    color: var(--ai-text-muted, #526579);
    font-size: 14px;
    line-height: 1.7;
}

.ai-service-flow { margin: 0 0 16px; padding: 10px 12px; color: #4d6578; font-size: 14px; line-height: 1.6; }
.ai-service-flow b { color: #2f4c63; margin-right: 10px; }
.ai-service-flow span { margin-right: 10px; }
.ai-service-flow strong { color: #247c87; }
.ai-service-flow-note { display: block; margin: 4px 0 7px; color: var(--ai-text-muted, #526579); }
.ai-service-flow .btn { margin-right: 4px; }

/* --------------------------------------------------------------- 모델 카드 */

.ai-card {
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid #e7ecf1;
    border-left-width: 4px;
    border-radius: 4px;
    background: #fff;
}

/* 왼쪽 띠로 지금 단계를 알립니다. 카드를 훑을 때 색만 봐도 갈립니다. */
.ai-card.state-READY    { border-left-color: #26c281; }
.ai-card.state-DEPLOY   { border-left-color: #3598dc; }
.ai-card.state-TRAIN,
.ai-card.state-PREPROCESS,
.ai-card.state-EVALUATE  { border-left-color: #f2a654; }
.ai-card.state-DRAFT    { border-left-color: #bac3d0; }
.ai-card.state-RETIRE   { border-left-color: #d3d7de; background: #fafbfc; }
.ai-card.is-unverified  { border-left-color: #f2a654; }
.ai-card.is-failed      { border-left-color: #e7505a; }
.ai-card.has-health-issue { border-top-color: #f2a654; border-right-color: #f2a654; }

.ai-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

/* 긴 모델 ID·상태·경고도 생략하지 않고 카드 안에서 줄을 바꿉니다. */
.ai-card-head > * {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.ai-card-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #3f444a;
}

.ai-card-id {
    color: var(--ai-text-muted, #526579);
    font-size: 14px;
}

.ai-card-ver {
    padding: 1px 8px;
    border-radius: 10px;
    background: #eef3f8;
    color: #5b6b7f;
    font-size: 12px;
    font-weight: 600;
}

.ai-card-spacer {
    flex: 1 1 auto;
}

/* 상태 딱지는 누를 수 있습니다. 누르면 그 일을 하는 자리로 갑니다. */
.ai-state {
    padding: 3px 10px;
    border: 0;
    border-radius: 12px;
    background: #eef3f8;
    color: #5b6b7f;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: normal;
}

.ai-state:hover {
    filter: brightness(0.95);
}

.ai-state.state-READY   { background: #e3f7ef; color: var(--ai-text-success, #196c47); }
.ai-state.state-DEPLOY  { background: #e6f1fa; color: #1f6ea8; }
.ai-state.state-TRAIN,
.ai-state.state-PREPROCESS,
.ai-state.state-EVALUATE { background: #fdf1e3; color: var(--ai-text-warning, #87500d); }
.ai-state.state-DRAFT   { background: #eef0f3; color: var(--ai-text-muted, #526579); }
.ai-state.state-RETIRE  { background: #eef0f3; color: var(--ai-text-muted, #526579); }
.ai-state.is-unverified { background: #fdf1e3; color: var(--ai-text-warning, #87500d); }
.ai-state.is-failed     { background: #fdecee; color: #c0392b; }

/* 상태 옆의 운영 문제는 같은 모델+버전에 묶인 점검 결과입니다. 상단 공통
   인프라 경고와 색을 달리해, 어디를 고쳐야 하는지 바로 구분합니다. */
.ai-model-issue {
    padding: 3px 9px;
    border: 1px solid #e7a13e;
    border-radius: 12px;
    background: #fff7e8;
    color: var(--ai-text-warning, #87500d);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: normal;
}

.ai-model-issue:hover { background: #fdf0d8; }

/* 언제부터 이러고 있나. 오래 걸리면 눈에 띄어야 합니다. */
.ai-elapsed {
    margin-left: 6px;
    color: var(--ai-text-muted, #526579);
    font-size: 14px;
}

.ai-elapsed.is-warn {
    color: #c0392b;
    font-weight: 600;
}

/* ------------------------------------------------------------- 기본 정보 */

.ai-card-info { margin: 8px 0; }
.ai-card-info > summary { display: list-item; list-style: disclosure-closed inside; cursor: pointer; color: var(--ai-text-link, #21618c); font-size: 14px; line-height: 1.7; }
.ai-card-info[open] > summary { list-style-type: disclosure-open; margin-bottom: 8px; }

.ai-model-versions { margin-top: 12px; padding-top: 10px; border-top: 1px solid #e7ecf1; }
.ai-model-versions > summary { cursor: pointer; color: var(--ai-text-link, #21618c); font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.ai-version-table { width: 100%; table-layout: fixed; margin-top: 10px; }
.ai-version-table th, .ai-version-table td { padding: 10px 8px; vertical-align: top; border-bottom: 1px solid #e7ecf1; overflow-wrap: anywhere; }
.ai-version-table th:first-child { width: 15%; }
.ai-version-table th:nth-child(2) { width: 25%; }
.ai-version-table .ai-actions { margin: 0; }
.ai-version-table .ai-used-asset { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
@media (max-width: 700px) {
    .ai-version-table, .ai-version-table tbody, .ai-version-table tr, .ai-version-table td { display: block; width: 100%; }
    .ai-version-table thead { display: none; }
    .ai-version-table tr { border-bottom: 2px solid #e7ecf1; padding: 6px 0; }
    .ai-version-table td { border: 0; padding: 5px 0; }
    .ai-version-table td::before { content: attr(data-label); display: block; color: var(--ai-text-muted, #526579); margin-bottom: 4px; }
}

.ai-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 4px 20px;
    margin: 10px 0 12px;
}

.ai-field {
    display: block;
    font-size: 14px;
    line-height: 1.7;
}

.ai-field dt {
    margin: 0 0 2px;
    color: var(--ai-text-muted, #526579);
    font-weight: 400;
}

.ai-field dd {
    margin: 0;
    color: #3f444a;
    word-break: break-word;
}

.ai-field dd.is-empty {
    color: var(--ai-text-muted, #526579);
}

/* --------------------------------------------------------- 다음 할 일·버튼 */

/* 상태를 읽어 한 가지를 짚어 줍니다. 버튼을 다 늘어놓으면 무엇을 할 차례인지
   사람이 기록을 보고 스스로 판단해야 합니다. */
.ai-next {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 3px;
    background: #f6f8fa;
    color: #5b6b7f;
    font-size: 14px;
    line-height: 1.6;
}

.ai-next.is-warn {
    background: #fdecee;
    color: #c0392b;
}

.ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.ai-actions .btn {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

.ai-actions .form-control {
    width: auto;
    min-width: 120px;
    height: 30px;
    padding: 4px 8px;
    font-size: 14px;
}

/* ------------------------------------------------------------------ 상세 */

.ai-detail-table {
    width: 100%;
    font-size: 14px;
}

.ai-detail-table th {
    width: 160px;
    padding: 6px 10px 6px 0;
    color: var(--ai-text-muted, #526579);
    font-weight: 400;
    text-align: left;
    vertical-align: top;
}

.ai-detail-table td {
    padding: 6px 0;
    color: #3f444a;
    word-break: break-all;
}

.ai-detail-table .ai-history-detail {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    vertical-align: top;
}

/* 작은 화면에서도 서비스 버전의 날짜·경로·작업을 한 항목씩 읽습니다. */
@media (max-width: 700px) {
    #ai-detail-body .ai-ledger-table,
    #ai-detail-body .ai-ledger-table tbody,
    #ai-detail-body .ai-ledger-table tr,
    #ai-detail-body .ai-ledger-table td { display: block; width: 100%; }
    #ai-detail-body .ai-ledger-table { overflow-x: visible; }
    #ai-detail-body .ai-ledger-table thead { display: none; }
    #ai-detail-body .ai-ledger-table tr { border-bottom: 1px solid #e7ecf1; padding: 8px 0; }
    #ai-detail-body .ai-ledger-table td { padding: 6px 0; word-break: normal; overflow-wrap: anywhere; }
    #ai-detail-body .ai-ledger-table td[data-label]::before {
        content: attr(data-label); display: block; margin-bottom: 4px;
        color: var(--ai-text-muted, #526579); font-weight: 600;
    }
    #ai-detail-body .ai-ledger-table .btn { white-space: normal; max-width: 100%; }
}

.ai-empty {
    padding: 30px;
    color: var(--ai-text-muted, #526579);
    text-align: center;
}

/* ------------------------------------------------------------ 모달 발치 */

/* 왼쪽 끝은 물러나는 것(취소), 오른쪽 끝은 나아가는 것(내리기).
   부트스트랩 기본은 둘 다 오른쪽에 붙여 놓아서, 손이 오른쪽 끝으로 갔을 때
   무엇인지를 매번 읽어야 합니다. 갈라 두면 위치가 곧 뜻입니다.

   ai_steps.css 에 같은 규칙이 있습니다. 두 파일을 같이 불러오지 못해서
   한 벌씩 둡니다 - 둘 다 .ai-state 를 쓰는데 뜻이 다릅니다(여기는 배포 상태
   딱지, 거기는 스텝 상태 딱지). 합치려면 그 이름부터 갈라야 합니다. */
.modal-footer.ai-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-footer.ai-foot .ai-foot-left  { flex: 0 0 auto; }
.modal-footer.ai-foot .ai-foot-right { flex: 0 0 auto; margin-left: auto; }
.modal-footer.ai-foot .ai-foot-right .btn { margin-left: 6px; }

/* 승인 모달의 고르개. 라디오와 글자가 붙어 있으면 어느 쪽 설명인지 헷갈립니다. */
.ai-radio {
    display: block;
    margin-bottom: 6px;
    font-weight: 400;
    color: #4a5b6b;
    font-size: 14px;
}

.ai-radio input { margin-right: 6px; }

/* ---------------------------------------------------------------------------
   배포 테이블 표 · 추론 시험 — 2026-09-18
   --------------------------------------------------------------------------- */

.ai-tag-ok   { color: #3a7d44; font-size: 14px; }
.ai-tag-wait { color: var(--ai-text-warning, #87500d); font-size: 14px; }
.ai-tag-bad  { color: #a04747; font-size: 14px; }
.ai-tag-latest { color: #1f6ea8; font-size: 14px; }

.ai-latest-badge {
    padding: 3px 9px;
    border-radius: 12px;
    background: #e6f1fa;
    color: #1f6ea8;
    font-size: 14px;
    font-weight: 600;
}

.ai-version-manager {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-left: 3px solid #3598dc;
    background: #f4f9fd;
    color: #4d6476;
    font-size: 14px;
    line-height: 1.6;
}

.ai-version-manager p { margin: 4px 0 0; }

.ai-unit { color: var(--ai-text-muted, #526579); font-weight: normal; }

.ai-warn-box {
    padding: 9px 12px; border-left: 3px solid #d9a441; background: #fdf8ef;
    color: #7a6132; font-size: 14px; line-height: 1.7; margin: 8px 0;
}

/* 추론 시험이 쓰는 것. ai_steps.css 에 같은 이름이 있지만 이 화면은 그 파일을
   안 싣습니다 - 한 화면이 쓰는 것은 그 화면의 css 에 있어야 합니다. */

.ai-asset-h { margin: 16px 0 6px; font-size: 16px; color: #34495e; }

#if-out .ai-asset-warn, #if-out .ai-warn-box { overflow-wrap: anywhere; }

.ai-code {
    background: #f7f8fa; border: 1px solid #e6e9ee; border-radius: 3px;
    padding: 10px 12px; font-size: 14px; line-height: 1.6; color: #34495e;
    max-height: 260px; overflow: auto; white-space: pre;
}

.ai-form label { display: block; font-size: 14px; color: #34495e; margin: 10px 0 4px; }
.ai-form.ai-infer-form { max-width: none; }

.ai-acts-right { text-align: right; margin-top: 14px; }

.ai-infer-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.ai-infer-actions .btn { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
#ai-detail-modal .modal-footer.ai-infer-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
#ai-detail-modal .ai-infer-footer::before, #ai-detail-modal .ai-infer-footer::after { display: none; }
#ai-detail-modal .ai-infer-footer > .btn { min-width: 0; max-width: 100%; margin: 0; white-space: normal; overflow-wrap: anywhere; }
#ai-detail-body details > summary { cursor: pointer; }
#ai-detail-body details > summary:focus-visible { outline: 2px solid #3598dc; outline-offset: 2px; }

/* ------------------------------------------------- 조용히 실패한 것 알림 */

/* 목록 위에 붙습니다. 화면에 안 보이던 것을 말하는 자리라, 이상이 없을 때도
   "무엇을 봤는지" 를 같이 적습니다 - 안 본 것과 이상 없는 것은 다릅니다. */
.ai-health {
    border: 1px solid #e4e8ee;
    border-left: 3px solid #b0b8c4;
    border-radius: 3px;
    padding: 10px 14px;
    margin: 0 0 14px;
    background: #fbfcfd;
}

.ai-health.is-ok    { border-left-color: #36c6d3; }

@media (min-width: 768px) {
    #ai-model-health .ai-health.is-ok {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 6px 14px;
    }
    #ai-model-health .is-ok > b,
    #ai-model-health .is-ok > span,
    #ai-model-health .is-ok > details { grid-column: 1; }
    #ai-model-health .is-ok > .clearfix { display: none; }
    #ai-model-health .is-ok > #ai-health-again {
        grid-column: 2;
        grid-row: 1 / 3;
        justify-self: end;
    }
    #ai-model-health .is-ok > p { grid-column: 1 / -1; margin: 0; }
    #ai-model-health .is-ok > p:last-child { grid-column: 2; justify-self: end; }
    #ai-model-health .is-ok > details { margin: 0; }
}

.ai-health.is-watch { border-left-color: #f0ad4e; }
.ai-health.is-bad   { border-left-color: #e7505a; }

.ai-health b { color: #34495e; font-size: 14px; }

.ai-health-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 6px;
}

.ai-health-list li {
    font-size: 14px;
    line-height: 1.7;
    color: #5c6873;
    padding: 4px 0;
    border-top: 1px solid #eef1f5;
}

.ai-health-list li:first-child { border-top: 0; }

.ai-health-tag {
    display: inline-block;
    font-size: 14px;
    padding: 1px 6px;
    border-radius: 2px;
    background: #eef1f5;
    color: #5c6873;
    margin-right: 4px;
}

.ai-health-list li.is-bad   .ai-health-tag { background: #fdeaeb; color: var(--ai-text-danger, #a52b35); }
.ai-health-list li.is-watch .ai-health-tag { background: #fdf3e3; color: var(--ai-text-warning, #87500d); }

.ai-health-more { font-size: 14px; margin-left: 4px; }

.ai-health-why {
    margin: 6px 0 2px;
    max-height: 260px;
    overflow: auto;
    font-size: 14px;
}

.ai-model-issue-detail {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #f0dfc6;
    border-left: 3px solid #e7a13e;
    background: #fffdf9;
}

.ai-model-issue-detail h5 { margin: 0 0 6px; color: #7a5420; font-size: 16px; }
.ai-model-issue-detail p { margin: 0 0 8px; font-size: 14px; line-height: 1.6; }
.ai-model-issue-detail .ai-model-issue-go { margin-bottom: 0; color: #5c6873; }

/* 이미지 확인에서 실행, 결과로 이어지는 추론 작업 영역입니다. */
.ai-infer-json { margin: 14px 0; }
.ai-infer-json .ai-code-edit { margin-top: 10px; }
.ai-infer-actions { padding: 12px 0; border-top: 1px solid #d7e1eb; border-bottom: 1px solid #d7e1eb; margin-bottom: 16px; }
.ai-infer-result:not(:empty) { padding: 14px 16px; border: 1px solid #c7d8e8; border-radius: 5px; background: #f8fbfe; margin: 16px 0; }
.ai-infer-result h5:first-child { margin-top: 0; }
.ai-prediction-summary { padding: 14px 16px; border-left: 4px solid #317799; background: #edf5fa; color: #1d3749; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.ai-prediction-summary > strong { display: inline-block; margin: 2px 0; font-size: 20px; line-height: 1.4; }
.ai-prediction-summary .ai-help { color: #425a6a; }
.ai-prediction-summary .table { margin-top: 10px; }
@media (max-width: 767px) { .ai-infer-actions .btn { flex: 1 1 150px; } }

.ai-infer-context { padding: 12px 14px; margin: 0 0 16px; border-left: 3px solid #21618c; background: #f1f6fb; color: #354f66; line-height: 1.7; overflow-wrap: anywhere; }
.ai-infer-context.is-warn { border-left-color: #d9a441; background: #fdf8ef; color: #87500d; }
