/* =========================================================
   Checklist copy table
   Окремі стилі лише для viewChecklistCopyU().
   Не залежать від #uTable / table1.js.
   ========================================================= */

.checklist-copy-table {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
    background: transparent;
    border-spacing: 0;
    border-collapse: collapse;
}

.checklist-copy-table th {
    text-align: left;
}

.checklist-copy-table > thead > tr > th,
.checklist-copy-table > tbody > tr > th,
.checklist-copy-table > tfoot > tr > th,
.checklist-copy-table > thead > tr > td,
.checklist-copy-table > tbody > tr > td,
.checklist-copy-table > tfoot > tr > td {
    padding: 8px;
    line-height: 1.42857143;
    vertical-align: top;
    border-top: 1px solid #ddd;
}

.checklist-copy-table > thead > tr > th {
    vertical-align: bottom;
    border-bottom: 2px solid #ddd;
}

.checklist-copy-table.table-striped > tbody > tr:nth-of-type(odd) {
    background-color: #f9f9f9;
}

.checklist-copy-table.table-hover > tbody > tr:hover {
    background-color: #f5f5f5;
}

.checklist-copy-table .checklist-copy-status,
.checklist-copy-table .checklist-copy-number {
    width: 1%;
    white-space: nowrap;
}

.checklist-copy-table .checklist-copy-status {
    text-align: left;
}

.checklist-copy-table .checklist-copy-task__name {
    margin-left: 0;
}

.checklist-copy-table .checklist-copy-actions {
    white-space: nowrap;
}

.checklist-copy-table .checklist-copy-actions__inner,
.checklist-copy-table .checklist-copy-status-actions {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}

.checklist-copy-table .checklist-copy-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

/* =========================================================
   Mobile: один <tr> = одна картка.

   Рядок 1: статус | №. | назва задачі — по лівому краю.
   Рядок 2: коментар — лише якщо він не порожній.
   Рядок 3: усі кнопки — по центру.
   ========================================================= */
@media (max-width: 768px) {

    .checklist-copy-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }

    .checklist-copy-table,
    .checklist-copy-table tbody {
        display: block;
        width: 100%;
    }

    .checklist-copy-table {
        margin: 0;
        border: 0;
    }

    .checklist-copy-table tbody tr.checklist-copy-row--default {
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr);
        column-gap: 8px;
        row-gap: 0;
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 12px;
        padding: 10px 12px;
        background: #fff;
        border: 1px solid #dee2e6;
        border-radius: 8px;
    }

    .checklist-copy-table.table-striped > tbody > tr.checklist-copy-row--default:nth-of-type(odd) {
        background-color: #f8f9fa;
    }

    .checklist-copy-table tbody tr.checklist-copy-row--default > td {
        width: auto;
        box-sizing: border-box;
        padding: 0;
        border-top: 0;
        text-align: left;
        overflow-wrap: anywhere;
    }

    /* На цій таблиці data-label не використовується. */
    .checklist-copy-table tbody tr.checklist-copy-row--default > td::before {
        display: none !important;
        content: none !important;
    }

    /* ---------- Рядок 1: статус + номер + задача ---------- */

    .checklist-copy-table .checklist-copy-status {
        grid-column: 1;
        grid-row: 1;
        align-self: start;
        width: auto;
        padding-top: 2px;
        text-align: left;
        white-space: nowrap;
    }

    .checklist-copy-table .checklist-copy-status > i {
        display: inline-block;
        vertical-align: top;
    }

    .checklist-copy-table .checklist-copy-number {
        grid-column: 2;
        grid-row: 1;
        align-self: start;
        width: auto;
        padding-top: 2px;
        text-align: left;
        white-space: nowrap;
    }

    .checklist-copy-table .checklist-copy-task {
        grid-column: 3;
        grid-row: 1;
        min-width: 0;
        text-align: left;
    }

    .checklist-copy-table .checklist-copy-task__name {
        display: block;
        min-width: 0;
        margin-left: 0;
        text-align: left;
        overflow-wrap: anywhere;
    }

    /* ---------- Рядок 2: коментар ---------- */

    .checklist-copy-table .checklist-copy-comment {
        grid-column: 1 / -1;
        width: 100%;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #e9ecef;
        text-align: left;
        white-space: normal;
    }

    .checklist-copy-table .checklist-copy-comment--empty {
        display: none;
    }

    /* ---------- Рядок 3: кнопки ---------- */

    .checklist-copy-table .checklist-copy-actions {
        grid-column: 1 / -1;
        width: 100%;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #e9ecef;
        text-align: center;
        white-space: normal;
    }

    .checklist-copy-table .checklist-copy-actions--empty {
        display: none;
    }

    .checklist-copy-table .checklist-copy-actions__inner {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: center;
        gap: 18px;
        flex-wrap: nowrap;
    }

    .checklist-copy-table .checklist-copy-status-actions {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 18px;
        flex-wrap: nowrap;
    }

    .checklist-copy-table .checklist-copy-action {
        flex: 0 0 auto;
    }

    /* ---------- Рядок-розділ ---------- */

    .checklist-copy-table tbody tr.checklist-copy-row--section {
        display: block;
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 12px;
        padding: 8px 12px;
        background: #fff;
        border: 1px solid #dee2e6;
        border-radius: 8px;
    }

    .checklist-copy-table tbody tr.checklist-copy-row--section > td {
        display: block;
        width: 100%;
        box-sizing: border-box;
        padding: 0;
        border-top: 0;
    }

    .checklist-copy-table .checklist-copy-section h4 {
        margin: 4px 0;
    }

    /*
     * Fallback для рідкісного випадку $context['control'].
     * Залишаємо стару структуру control-файлу працездатною,
     * але не намагаємося автоматично об'єднувати його <td>.
     */
    .checklist-copy-table tbody tr.checklist-copy-row--custom {
        display: block;
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 12px;
        padding: 4px 12px;
        background: #fff;
        border: 1px solid #dee2e6;
        border-radius: 8px;
    }

    .checklist-copy-table tbody tr.checklist-copy-row--custom > td {
        display: block;
        width: 100%;
        box-sizing: border-box;
        padding: 9px 0;
        border-top: 1px solid #e9ecef;
    }

    .checklist-copy-table tbody tr.checklist-copy-row--custom > td:first-child {
        border-top: 0;
    }
}

@media (max-width: 480px) {
    .checklist-copy-table .checklist-copy-actions__inner,
    .checklist-copy-table .checklist-copy-status-actions {
        gap: 14px;
    }
}
