//
// _datatables.scss
//

.dt-scroll {
    width: 100%;

    .dt-scroll-body {

        thead tr,
        tfoot tr {
            height: 0;
        }

        thead tr,
        tfoot tr {

            th,
            td {
                height: 0 !important;
                padding-top: 0 !important;
                padding-bottom: 0 !important;
                border-top-width: 0 !important;
                border-bottom-width: 0 !important;

                .dt-scroll-sizing {
                    height: 0 !important;
                    overflow: hidden !important;
                }
            }
        }
    }
}

table.dataTable {

    thead>tr,
    tfoot>tr {

        th,
        td {
            .dt-column-order {
                opacity: 0;
            }

            &:hover,
            &.dt-ordering-asc,
            &.dt-ordering-desc {
                .dt-column-order {
                    opacity: 1;
                }
            }

            &.dt-orderable-asc span.dt-column-order::before,
            &.dt-ordering-asc span.dt-column-order::before {
                position: absolute;
                display: block;
                bottom: 50%;
                content: '\ea62'; /* Tabler icon for up-arrow (ascending) */
                font-family: "tabler-icons";
            }

            &.dt-orderable-desc span.dt-column-order::after,
            &.dt-ordering-desc span.dt-column-order::after {
                position: absolute;
                display: block;
                top: 50%;
                content: '\ea5f'; /* Tabler icon for down-arrow (descending) */
                font-family: "tabler-icons";
            }


            &.dt-orderable-asc,
            &.dt-orderable-desc,
            &.dt-ordering-asc,
            &.dt-ordering-desc {
                span.dt-column-order {
                    position: relative;
                    width: 12px;
                    height: 20px;

                    &:before,
                    &:after {
                        left: 0;
                        opacity: 0.25;
                        line-height: 9px;
                        font-size: 0.8125rem;
                        font-weight: $font-weight-semibold;
                    }
                }
            }

            &.dt-ordering-asc span.dt-column-order:before,
            &.dt-ordering-desc span.dt-column-order:after {
                opacity: 0.6;
            }

            &.sorting_asc_disabled span.dt-column-order:before,
            &.sorting_desc_disabled span.dt-column-order:after {
                display: none;
            }

            &:active {
                outline: none;
            }

            div.dt-column-header,
            div.dt-column-footer {
                display: flex;
                justify-content: space-between;
                align-items: center;
                gap: 4px;

                span.dt-column-title {
                    flex-grow: 1;

                    &:empty {
                        display: none;
                    }
                }
            }
        }
    }

    tbody {

        >tr.selected,
        >tr>.selected {
            background-color: rgba(var(--#{$prefix}warning-rgb), 0.1);
            color: inherit;

            td {
                background-color: rgba(var(--#{$prefix}warning-rgb), 0.1);
                color: inherit;
            }
        }
    }
}

div.dt-scroll-body {
    >table.dataTable {

        >thead>tr>th,
        >thead>tr>td {
            overflow: hidden;
        }
    }
}

.dt-processing {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    margin-left: -50px;
    margin-top: -22px;
    text-align: center;
    padding: 2px;
    z-index: 10;
    border: 1px solid var(--#{$prefix}border-color);

    >div:last-child {
        position: relative;
        width: 80px;
        height: 15px;
        margin: 1em auto;

        >div {
            position: absolute;
            top: 0;
            width: 13px;
            height: 13px;
            border-radius: 50%;
            background: var(--#{$prefix}primary);
            animation-timing-function: cubic-bezier(0, 1, 1, 0);

            &:nth-child(1) {
                left: 8px;
                animation: datatables-loader-1 0.6s infinite;
            }

            &:nth-child(2) {
                left: 8px;
                animation: datatables-loader-2 0.6s infinite;
            }

            &:nth-child(3) {
                left: 32px;
                animation: datatables-loader-2 0.6s infinite;
            }

            &:nth-child(4) {
                left: 56px;
                animation: datatables-loader-3 0.6s infinite;
            }
        }
    }
}

@keyframes datatables-loader-1 {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes datatables-loader-3 {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(0);
    }
}

@keyframes datatables-loader-2 {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(24px, 0);
    }
}

table.dataTable {
    &.nowrap {

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

    th,
    td {
        box-sizing: border-box;

        &.dt-left {
            text-align: left;

            div.dt-column-header,
            div.dt-column-footer {
                flex-direction: row;
            }
        }

        &.dt-center {
            text-align: center;
        }

        &.dt-right {
            text-align: right;

            div.dt-column-header,
            div.dt-column-footer {
                flex-direction: row-reverse;
            }
        }

        &.dt-justify {
            text-align: justify;

            div.dt-column-header,
            div.dt-column-footer {
                flex-direction: row;
            }
        }

        &.dt-nowrap {
            white-space: nowrap;
        }

        &.dt-empty {
            text-align: center;
            vertical-align: top;
        }
    }

    thead,
    tfoot {

        th,
        td {
            text-align: left;

            &.dt-head-left {
                text-align: left;

                div.dt-column-header,
                div.dt-column-footer {
                    flex-direction: row;
                }
            }

            &.dt-head-center {
                text-align: center;
            }

            &.dt-head-right {
                text-align: right;

                div.dt-column-header,
                div.dt-column-footer {
                    flex-direction: row-reverse;
                }
            }

            &.dt-head-justify {
                text-align: justify;

                div.dt-column-header,
                div.dt-column-footer {
                    flex-direction: row;
                }
            }

            &.dt-head-nowrap {
                white-space: nowrap;
            }
        }
    }

    tbody {

        th,
        td {
            &.dt-body-left {
                text-align: left;
            }

            &.dt-body-center {
                text-align: center;
            }

            &.dt-body-right {
                text-align: right;
            }

            &.dt-body-justify {
                text-align: justify;
            }

            &.dt-body-nowrap {
                white-space: nowrap;
            }
        }
    }
}


/*! Bootstrap 5 integration for DataTables
 *
 * ©2020 SpryMedia Ltd, all rights reserved.
 * License: MIT datatables.net/license/mit
 */
table.table.dataTable {
    clear: both;
    margin-bottom: 0;
    max-width: none;
    border-spacing: 0;
}

.dt-container {
    position: relative;
    margin-top: -0.75rem;

    .dt-layout-start {
        >*:not(:last-child) {
            margin-right: 1em;
        }
    }

    .dt-layout-end {
        >*:not(:first-child) {
            margin-left: 1em;
        }
    }

    .dt-layout-full {
        width: 100%;

        >*:only-child {
            margin-left: auto;
            margin-right: auto;
        }
    }

    .dt-layout-table {
        >div {
            display: block !important;
        }
    }

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

        select {
            width: auto;
            display: inline-block;
            margin-right: 0.5em;
        }
    }

    .dt-search {
        text-align: right;

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

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

    .dt-paging {
        margin: 0;

        ul.pagination {
            margin: 0;
            flex-wrap: wrap;
            padding-top: calc(var(--#{$prefix}card-spacer-y) - .75rem);
        }
    }

    .dt-row {
        position: relative;
    }

    .dt-info {
        padding-top: calc(var(--#{$prefix}card-spacer-y) - .75rem);
    }
}

// Responsive overrides
@media screen and (max-width: 767px) {
    .dt-container {
        .dt-layout-start {
            >*:not(:last-child) {
                margin-right: 0;
            }
        }

        .dt-layout-end {
            >*:not(:first-child) {
                margin-left: 0;
            }
        }
    }
}

.dt-scroll-head {
    table.dataTable {
        margin-bottom: 0 !important;
    }

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

.dt-scroll-body {
    >table {
        border-top: none;
        margin-top: 0 !important;
        margin-bottom: 0 !important;

        >thead>tr {
            border-width: 0 !important;
        }

        >tbody {
            >tr:first-child {
                border-top-width: 0;
            }

            // >tr:last-child {
            //     >* {
            //         border-bottom: none;
            //     }
            // }
        }
    }
}

.dt-scroll-foot {
    >.dt-scroll-footInner {
        box-sizing: content-box;

        >table {
            margin-top: 0 !important;
            border-top: none;

            >tfoot>tr:first-child {
                border-top-width: 0 !important;
            }
        }
    }
}

// Responsive styles
@media screen and (max-width: 767px) {
    .dt-container {

        div.dt-length,
        div.dt-search,
        div.dt-info,
        div.dt-paging {
            text-align: center;
        }

        .row {
            --bs-gutter-y: 0.5rem;
        }

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

.table-responsive {
    >.dt-container {
        >.row {
            margin: 0;

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

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

// Select Info
.select-info {
    background-color: var(--#{$prefix}warning-bg-subtle);
    padding: 3px 6px;
    border-radius: 3px;
    font-weight: $font-weight-semibold;

    .select-item {
        margin: 0 !important;
    }
}

// Data Table copy button
div.dt-button-info {
    background-color: var(--#{$prefix}primary);
    border: none;
    color: $white;
    box-shadow: none;
    border-radius: 3px;
    text-align: center;
    z-index: 21;

    h2 {
        border-bottom: none;
        background-color: rgba($white, 0.2);
        color: $white;
    }
}

// Fixed Header
.dtfh-floatingparent-head {
    top: $topbar-height !important;
}

table.dataTable.fixedHeader-floating,
table.dataTable.fixedHeader-locked {
    background-color: var(--#{$prefix}body-bg);
}

@media screen and (max-width: 767px) {

    div.dt-container div.dt-length,
    div.dt-container div.dt-search,
    div.dt-container div.dt-info,
    div.dt-container div.dt-paging {
        text-align: center;
    }

    .dt-paging {
        .pagination {
            justify-content: center;
        }
    }

    .dt-length {
        margin-bottom: 10px;
    }
}

// Fixed Column
table.dataTable {
  thead,
  tfoot {
    tr {
      > .dtfc-fixed-start,
      > .dtfc-fixed-end {
        background-color: var(--#{$prefix}secondary-bg);
      }
    }
  }

  tbody {
    tr {
      > .dtfc-fixed-start,
      > .dtfc-fixed-end {
        background-color: var(--#{$prefix}secondary-bg);
      }
    }
  }
}

.dtfc-top-blocker,
.dtfc-bottom-blocker {
  background-color: var(--#{$prefix}body-bg);
}

.dt-scroll-body {
  border-left-color: var(--#{$prefix}table-color) !important;
}

.dt-scroll-headInner,
.dt-scroll-footInner {
  table.table-bordered {
    tr {
      th:first-child {
        border-left-color: var(--#{$prefix}border-color) !important;
      }
    }
  }
}


//Column Search
.column-search-input-bar {
    .dt-column-order {
        display: none;
    }
}