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

table.dataTable {
    clear: both;
    margin-top: 6px !important;
    margin-bottom: 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: left;
            white-space: nowrap;
        }

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

    &.dataTables_filter {
        text-align: right;

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

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

    &.dataTables_info {
        padding-top: 0.85em;
    }

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

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

    &.dataTables_processing {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 200px;
        margin-left: -100px;
        margin-top: -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-right: 30px;
        }
    }

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

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

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

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

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

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

    .sorting:before,
    .sorting_asc:before,
    .sorting_desc:before,
    .sorting_asc_disabled:before,
    .sorting_desc_disabled:before {
        right: 1em;
        content: "↑";
    }

    .sorting:after,
    .sorting_asc:after,
    .sorting_desc:after,
    .sorting_asc_disabled:after,
    .sorting_desc_disabled:after {
        right: 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-bottom: 0 !important;
    }

    &.dataTables_scrollBody table {
        border-top: none;
        margin-top: 0 !important;
        margin-bottom: 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-top: none;
            }
        }
    }

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

        > table {
            margin-top: 0 !important;
            border-top: 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-right: 20px;
        }

        .sorting:before,
        .sorting_asc:before,
        .sorting_desc:before {
            top: 5px;
            right: 0.85em;
        }

        .sorting:after,
        .sorting_asc:after,
        .sorting_desc:after {
            top: 5px;
        }
    }

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

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

        th,
        td {
            border-left-width: 0;
        }

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

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

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

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

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

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

            &:last-child {
                padding-right: 0;
            }
        }
    }
}

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

#delete-datatable tr {
    cursor: pointer;
}
