/*
 * Màn hình Checklist chuẩn (MH05). Mobile-first; nạp sau style-studio.css và style-detail.css.
 * Mục kiểm tra: dạng thẻ trên mobile, dạng bảng từ 768px. Bảng nhóm / loại sản phẩm cuộn ngang trên mobile.
 */

.checklist-template-heading { flex-wrap: wrap; gap: 14px; }
.checklist-template-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Thanh lọc ---------- */
.checklist-template-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 14px; }
.checklist-template-toolbar .studio-field select { background-color: #fff; }
.checklist-template-search { align-self: end; background: #fff; }
.checklist-template-switch { display: inline-flex; min-height: 44px; align-items: center; gap: 10px; margin: 0; color: var(--studio-text); font-size: 14px; cursor: pointer; }
.checklist-template-switch .form-check-input { width: 20px; height: 20px; flex: 0 0 auto; margin: 0; }
.checklist-template-switch .form-check-input:checked,
.template-item-select .form-check-input:checked { border-color: var(--studio-green-dark); background-color: var(--studio-green-dark); }
.checklist-template-add { justify-content: center; }

.checklist-template-selection-bar { position: sticky; top: 8px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; padding: 10px 12px; border: 1px solid #d6ddcf; border-radius: 10px; background: var(--studio-green-soft); }
.checklist-template-selection-bar strong { color: var(--studio-green-darker); font-size: 14px; }
.checklist-template-selection-bar .text-link { border: 0; background: none; }

.checklist-template-list-container { transition: opacity .15s; }
.checklist-template-list-container.is-loading { opacity: .55; pointer-events: none; }
.checklist-template-caption { margin: 0 0 10px; color: var(--studio-muted); font-size: 13px; }

/* ---------- Danh sách mục (thẻ trên mobile) ---------- */
.template-item-list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
/* Mobile: mức độ, giai đoạn, nhóm nằm chung một dòng dưới tên mục */
.template-item-row {
    display: grid;
    grid-template-columns: 32px auto auto minmax(0, 1fr);
    grid-template-areas:
        "select code code code"
        "select titles titles titles"
        "select priority stage group"
        "actions actions actions actions";
    align-items: center;
    gap: 4px 8px;
    padding: 12px;
    border: 1px solid var(--studio-line);
    border-radius: 10px;
    background: #fff;
}
.template-item-row.is-inactive { background: #f7f7f4; }
.template-item-row.is-inactive .template-item-titles strong { color: var(--studio-muted); text-decoration: line-through; text-decoration-color: #c9cbc4; }
.template-item-row.is-selected { border-color: #a8b79c; box-shadow: 0 0 0 2px var(--studio-green-soft); }
.template-item-header { display: none; }
.template-item-select { grid-area: select; display: flex; align-self: start; padding-top: 2px; }
.template-item-select .form-check-input { width: 22px; height: 22px; margin: 0; }
.template-item-code { grid-area: code; }
.template-item-titles { grid-area: titles; min-width: 0; }
.template-item-titles strong { display: block; color: var(--studio-ink); font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.template-item-titles small { display: block; margin-top: 2px; color: var(--studio-green-dark); font-size: 12px; }
.template-item-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.template-item-badges:empty { display: none; }
.template-item-inactive-badge { display: inline-flex; padding: 1px 7px; border-radius: 999px; background: #ecece8; color: var(--studio-muted); font-size: 10px; font-weight: 600; line-height: 16px; }
.template-item-priority { grid-area: priority; }
.template-item-stage { grid-area: stage; }
.template-item-group { grid-area: group; min-width: 0; overflow: hidden; color: var(--studio-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.template-item-actions { grid-area: actions; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--studio-line-soft); }
.template-item-actions .icon-action-button { width: 44px; height: 44px; }
.template-item-icon-up { transform: rotate(180deg); }

/* ---------- Bảng nhóm / loại sản phẩm ---------- */
.checklist-reference-heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.checklist-reference-heading h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.checklist-reference-heading p { margin: 0; color: var(--studio-muted); font-size: 13px; }
.checklist-reference-table-wrap { overflow-x: auto; border: 1px solid var(--studio-line); border-radius: 10px; background: #fff; -webkit-overflow-scrolling: touch; }
.checklist-reference-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; }
.checklist-reference-table th { padding: 10px 12px; border-bottom: 1px solid var(--studio-line); background: #fafaf7; color: var(--studio-muted); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
.checklist-reference-table td { padding: 10px 12px; border-bottom: 1px solid var(--studio-line-soft); color: var(--studio-text); vertical-align: middle; }
.checklist-reference-table tr:last-child td { border-bottom: 0; }
.checklist-reference-table tr.is-inactive td { background: #f7f7f4; }
.checklist-reference-table td strong { display: block; color: var(--studio-ink); }
.checklist-reference-table td small { display: block; color: var(--studio-green-dark); font-size: 12px; }
.checklist-reference-table .is-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.checklist-reference-actions { white-space: nowrap; text-align: right; }
.checklist-reference-actions .icon-action-button + .icon-action-button { margin-left: 6px; }
.garment-type-cell { display: flex; align-items: center; gap: 10px; }
.garment-type-thumb { width: 48px; height: 40px; flex: 0 0 auto; border-radius: 8px; }
.garment-type-thumb .art-label { display: none; }

/* ---------- Hộp thoại ---------- */
.checklist-template-modal-dialog { max-width: 620px; }
.checklist-readonly-input { background: #f6f6f3 !important; color: var(--studio-muted) !important; }
.studio-field input[readonly] { background: #f6f6f3; color: var(--studio-muted); }
.checklist-template-textarea { width: 100%; min-height: 64px; padding: 10px 12px; border: 1px solid #e0e1db; border-radius: 8px; color: var(--studio-ink); font-size: 16px; resize: vertical; }
.checklist-template-textarea:focus { border-color: #a8b79c; outline: 0; box-shadow: 0 0 0 3px var(--studio-green-soft); }
.checklist-template-checkboxes { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.checklist-template-extras { padding: 10px 12px; border: 1px dashed var(--studio-line); border-radius: 8px; }
.checklist-template-extras summary { min-height: 32px; color: var(--studio-text); font-size: 13px; font-weight: 600; cursor: pointer; }
.checklist-template-extras[open] summary { margin-bottom: 12px; }
.checklist-template-extras .studio-field + .studio-field,
.checklist-template-extras .studio-field-row + .studio-field { margin-top: 12px; }
.checklist-file-input { padding-top: 9px !important; }
.checklist-import-result { padding: 12px 14px; border: 1px solid var(--studio-line); border-radius: 10px; background: #fafaf7; font-size: 14px; }
.checklist-import-result h3 { margin: 0 0 6px; font-size: 14px; font-weight: 700; }
.checklist-import-result p { margin: 0 0 6px; }
.checklist-import-result ul { margin: 0; padding-left: 18px; }
.checklist-import-result.is-error { border-color: #f0dcd5; background: var(--studio-danger-soft); }
.checklist-import-errors { max-height: 220px; margin-top: 8px !important; overflow-y: auto; color: var(--studio-danger); font-size: 13px; }
.checklist-import-errors:empty { display: none; }

@media (min-width: 576px) {
    .checklist-template-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .checklist-template-search { grid-column: 1 / -1; }
}

/* Từ tablet: danh sách mục thành bảng */
@media (min-width: 768px) {
    .checklist-template-toolbar { grid-template-columns: 220px 220px minmax(0, 1fr); align-items: end; }
    .checklist-template-search { grid-column: auto; }
    .checklist-template-switch { grid-column: 1 / 3; }
    .checklist-template-add { justify-self: end; }

    .template-item-list { gap: 0; overflow: hidden; border: 1px solid var(--studio-line); border-radius: 10px; background: #fff; }
    .template-item-row {
        grid-template-columns: 32px 92px minmax(0, 1fr) 150px 82px 96px auto;
        grid-template-areas: none;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border: 0;
        border-bottom: 1px solid var(--studio-line-soft);
        border-radius: 0;
    }
    .template-item-row > * { grid-area: auto; }
    .template-item-row:last-child { border-bottom: 0; }
    .template-item-row.is-selected { box-shadow: inset 3px 0 0 var(--studio-green); }
    .template-item-header { display: grid; background: #fafaf7; color: var(--studio-muted); font-size: 12px; font-weight: 600; }
    .template-item-select { align-self: center; padding-top: 0; }
    .template-item-group { white-space: normal; }
    .template-item-actions { flex-wrap: nowrap; margin-top: 0; padding-top: 0; border-top: 0; }
    .template-item-actions .icon-action-button { width: 36px; height: 36px; }
    .template-item-actions-title { text-align: right; }
}

@media (min-width: 1200px) {
    .checklist-template-toolbar { grid-template-columns: 220px 240px minmax(0, 1fr) auto auto; }
    .checklist-template-switch { grid-column: auto; }
}
