/*! Bootstrap 5 integration for DataTables
 *
 * ©2020 SpryMedia Ltd, all rights reserved.
 * License: MIT datatables.net/license/mit
 */

table.dataTable {
    clear: both;
    margin-block-start: 6px !important;
    margin-block-end: 6px !important;
    max-width: none !important;
    border-collapse: separate !important;
    border-spacing: 0;

    td,
    th {
        -webkit-box-sizing: content-box;
        box-sizing: content-box;
    }

    td.dataTables_empty,
    th.dataTables_empty {
        text-align: center;
    }

    &.nowrap {
        th,
        td {
            white-space: nowrap;
        }
    }
}

div.dataTables_wrapper div {
    &.dataTables_length {
        label {
            font-weight: normal;
            text-align: start;
            white-space: nowrap;
        }

        select {
            width: auto;
            display: inline-block;
        }
    }

    &.dataTables_filter {
        text-align: end;

        label {
            font-weight: normal;
            white-space: nowrap;
            text-align: start;
        }

        input {
            margin-inline-start: 0.5em;
            display: inline-block;
            width: auto;
            margin-block-start: 2px;
        }
    }

    &.dataTables_info {
        padding-block-start: 0.85em;
    }

    &.dataTables_paginate {
        margin: 0;
        white-space: nowrap;
        text-align: end;

        ul.pagination {
            margin: 2px 0;
            white-space: nowrap;
            justify-content: flex-end;
        }
    }

    &.dataTables_processing {
        position: absolute;
        inset-block-start: 50%;
        inset-inline-start: 50%;
        width: 200px;
        margin-inline-start: -100px;
        margin-block-start: -26px;
        text-align: center;
        padding: 1em 0;
    }
}

table.dataTable > thead {
    > tr > {
        th:active,
        td:active {
            outline: none;
        }

        th:not(.sorting_disabled),
        td:not(.sorting_disabled) {
            padding-inline-end: 30px;
        }
    }

    .sorting,
    .sorting_asc,
    .sorting_desc,
    .sorting_asc_disabled,
    .sorting_desc_disabled {
        cursor: pointer;
        position: relative;
    }

    .sorting {
        &:before,
        &:after {
            position: absolute;
            inset-block-end: 0.5em;
            display: block;
            opacity: 0.3;
        }
    }

    .sorting_asc {
        &:before,
        &:after {
            position: absolute;
            inset-block-end: 0.5em;
            display: block;
            opacity: 0.3;
        }
    }

    .sorting_desc {
        &:before,
        &:after {
            position: absolute;
            inset-block-end: 0.5em;
            display: block;
            opacity: 0.3;
        }
    }

    .sorting_asc_disabled {
        &:before,
        &:after {
            position: absolute;
            inset-block-end: 0.5em;
            display: block;
            opacity: 0.3;
        }
    }

    .sorting_desc_disabled {
        &:before,
        &:after {
            position: absolute;
            inset-block-end: 0.5em;
            display: block;
            opacity: 0.3;
        }
    }

    .sorting:before,
    .sorting_asc:before,
    .sorting_desc:before,
    .sorting_asc_disabled:before,
    .sorting_desc_disabled:before {
        inset-inline-end: 1em;
        content: "↑";
    }

    .sorting:after,
    .sorting_asc:after,
    .sorting_desc:after,
    .sorting_asc_disabled:after,
    .sorting_desc_disabled:after {
        inset-inline-end: 0.5em;
        content: "↓";
    }

    .sorting_asc:before,
    .sorting_desc:after {
        opacity: 1;
    }

    .sorting_asc_disabled:before,
    .sorting_desc_disabled:after {
        opacity: 0;
    }
}

div {
    &.dataTables_scrollHead table.dataTable {
        margin-block-end: 0 !important;
    }

    &.dataTables_scrollBody table {
        border-block-start: none;
        margin-block-start: 0 !important;
        margin-block-end: 0 !important;

        thead {
            .sorting:before,
            .sorting_asc:before,
            .sorting_desc:before,
            .sorting:after,
            .sorting_asc:after,
            .sorting_desc:after {
                display: none;
            }
        }

        tbody tr:first-child {
            th,
            td {
                border-block-start: none;
            }
        }
    }

    &.dataTables_scrollFoot > .dataTables_scrollFootInner {
        box-sizing: content-box;

        > table {
            margin-block-start: 0 !important;
            border-block-start: none;
        }
    }
}

@media screen and (max-width: 767px) {
    div.dataTables_wrapper div {
        &.dataTables_length,
        &.dataTables_filter,
        &.dataTables_info {
            text-align: center !important;
        }

        &.dataTables_paginate {
            text-align: center !important;

            ul.pagination {
                justify-content: center !important;
            }
        }
    }
}

table {
    &.dataTable.table-sm {
        > thead > tr > th:not(.sorting_disabled) {
            padding-inline-end: 20px;
        }

        .sorting:before,
        .sorting_asc:before,
        .sorting_desc:before {
            inset-block-start: 5px;
            inset-inline-end: 0.85em;
        }

        .sorting:after,
        .sorting_asc:after,
        .sorting_desc:after {
            inset-block-start: 5px;
        }
    }

    &.table-bordered.dataTable {
        border-inline-end-width: 0;

        thead tr:first-child {
            th,
            td {
                border-block-start-width: 1px;
            }
        }

        th,
        td {
            border-inline-start-width: 0;
        }

        th:first-child,
        td:first-child {
            border-inline-start-width: 0px;
        }

        th:last-child,
        td:last-child {
            border-inline-end-width: 1px;
        }

        th,
        td {
            border-block-end-width: 0px;
        }
    }
}

div {
    &.dataTables_scrollHead table.table-bordered {
        border-block-end-width: 0;
    }

    &.table-responsive > div.dataTables_wrapper > div.row {
        margin: 0;

        > div[class^="col-"] {
            &:first-child {
                padding-inline-start: 0;
            }

            &:last-child {
                padding-inline-end: 0;
            }
        }
    }
}

.dataTables_wrapper .selected {
    background: #f6f6fb;
    cursor: pointer;
}

#delete-datatable tr {
    cursor: pointer;
}
