/* ========================================
   ТАБЛИЦЫ
   ======================================== */

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border: 1px solid var(--gray);
    border-radius: 3px;
    border-spacing: 0;
    background-color: var(--white);
    color: var(--black);
    font-size: 14px;
    text-align: center;
}

caption {
    margin-bottom: 5px;
    padding: 0 5px 0 10px;
    border-left: 3px solid var(--gray-dark);
    color: var(--black);
    font-size: 110%;
    text-align: left;
}

th {
    padding: 10px;
    border-right: 1px solid var(--gray);
    border-bottom: 1px solid var(--gray);
    background-color: var(--gray-light);
    color: var(--black);
    font-weight: bold;
    white-space: nowrap;
}

td {
    padding: 6px;
    border-right: 1px solid var(--gray);
    border-bottom: 1px solid var(--gray);
    vertical-align: middle;
}

th:last-child,
td:last-child {
    border-right: 0;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:nth-child(even) {
    background-color: var(--gray-light);
}

tbody tr:hover {
    background-color: var(--green-light);
}

th a {
    color: var(--black);
    text-decoration: none;
}

th a:hover {
    color: var(--green-dark);
    text-decoration: underline;
}


/* Выравнивание */

.table-left {
    text-align: left;
}

.table-center {
    text-align: center;
}

.table-right {
    text-align: right;
}


/* Состояния строк */

.table-row-success {
    background-color: var(--green-light) !important;
}

.table-row-warning {
    background-color: var(--yellow-light) !important;
}

.table-row-danger {
    background-color: var(--red-light) !important;
}

.table-row-danger-medium {
    background-color: var(--red-medium) !important;
}

.table-row-plain {
    background-color: var(--white) !important;
}


/* Компактная таблица */

.table-compact th {
    padding: 6px;
}

.table-compact td {
    padding: 4px 6px;
}


/* Мобильная таблица заказов */

.table-status-cargo-mobile {
    display: none;
}

@media (max-width: 600px) {
    .table-wrap--mobile-fit {
        overflow-x: hidden;
    }

    .table-mobile-orders {
        min-width: 0;
        table-layout: fixed;
        font-size: 12px;
    }

    .table-mobile-orders th,
    .table-mobile-orders td {
        min-width: 0;
        padding: 4px;
    }

    .table-mobile-orders thead th:nth-child(2),
    .table-mobile-orders thead th:nth-child(3),
    .table-mobile-orders thead th:nth-child(4),
    .table-mobile-orders tbody td:nth-child(2),
    .table-mobile-orders tbody td:nth-child(4) {
        vertical-align: middle;
        white-space: nowrap;
    }

    .table-mobile-orders .table-text-vertical {
        display: inline-block;
        -webkit-writing-mode: vertical-rl;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
        transform-origin: center;
        white-space: nowrap;
    }

    .table-mobile-orders thead th:nth-child(2),
    .table-mobile-orders thead th:nth-child(3),
    .table-mobile-orders thead th:nth-child(4) {
        height: 70px;
    }

    .table-mobile-orders th:first-child,
    .table-mobile-orders th:last-child,
    .table-mobile-orders td:first-child,
    .table-mobile-orders td:last-child {
        overflow-wrap: anywhere;
        white-space: normal;
        word-break: break-word;
    }

    .table-status-cargo-desktop {
        display: none;
    }

    .table-status-cargo-mobile {
        display: inline;
    }
}


/* Компактная кнопка действия */

.responsive-row > button.table-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 24px;
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    height: 22px;
    padding: 0;
    line-height: 1;
}

.table-action-button--danger:hover,
.table-action-button--danger:focus-visible {
    border-color: var(--red-dark);
    background-color: var(--red-dark);
    color: var(--white);
}


/* Текстовая кнопка — ширина по содержимому */

.responsive-row > button.table-action-button.name {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0 6px;
    white-space: nowrap;
}


/* Мобильная версия */

@media (max-width: 600px) {
    .table-wrap table {
        min-width: 650px;
    }

    .table-wrap--mobile-fit .table-mobile-orders {
        min-width: 0;
    }

    th,
    td {
        padding: 4px;
        font-size: 12px;
    }

    .responsive-row.table-row-action {
        align-items: center;
        flex-direction: row;
    }

    .responsive-row.table-row-action > .responsive-row__fill {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
    }

    .table-mobile-orders tbody td:last-child:not([colspan])
        > .responsive-row.table-row-action {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 24px;
        column-gap: 4px;
        row-gap: 4px;
    }

    .table-mobile-orders tbody td:last-child:not([colspan])
        > .responsive-row.table-row-action
        > .responsive-row__fill {
        grid-column: 1;
        grid-row: 1 / span 2;
    }

    .table-mobile-orders tbody td:last-child:not([colspan])
        > .responsive-row.table-row-action
        > button.table-action-button {
        grid-column: 2;
        margin: 0;
    }
}
