/* ###### 4.1 Datatables ###### */

table.dataTable {
  border: 1px solid #{$border};

  thead {

    th,
    td {
      border-block-start-width: 0;
      border-block-end-width: 0;
      padding: 15px 10px;
      font-weight: 500;
      font-size: 14px;
      color: #{$gray-900};
    }

    .sorting_asc,
    .sorting_desc {
      background-image: none;
      position: relative;
    }

    .sorting_asc::after,
    .sorting_desc::after {
      font-family: "Ionicons";
      font-size: 11px;
      position: absolute;
      line-height: 0;
      inset-block-start: 50%;
      inset-inline-end: 10px;
    }

    .sorting_asc::after {
      content: "\f3d8";
    }

    .sorting_desc::after {
      content: "\f3d0";
    }

    .sorting {
      background-image: none;
      position: relative;

      &::after {
        font-family: "Ionicons";
        font-size: 11px;
        position: absolute;
        line-height: 0;
        inset-inline-end: 10px;
      }

      &::after {
        content: "\f3d0" !important;
        inset-block-start: 50%;
        inset-inline-end: 1rem !important;
      }

      &.sorting_asc::after {
        content: "\f3d8" !important;
      }

      &.sorting_desc::after {
        opacity: 0.3;
      }
    }
  }

  &.dtr-inline.collapsed>tbody>tr[role="row"]>td:first-child::before {
    inset-block-start: 9.5px;
    inset-inline-start: 7px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-width: 0;
    box-shadow: none;
    background-color: rgb($background-gradient-color);
    font-size: 14px;
    font-weight: 700;
    color: #{$gray-500};
  }

  >tbody>tr.child {
    ul.dtr-details {
      display: block;
    }

    span.dtr-title {
      font-weight: 500;
    }
  }
}

.dataTables_wrapper {
  .selected {
    background: #{$primary-005}  !important;

    td {
      color: #{$muted};
    }
  }

  .dataTables_length {
    text-align: start;

    label {
      display: block;
      margin-block-end: 0px !important;
    }

    .select2-container--default {
      margin-inline-end: 5px;
      width: 65px !important;

      .select2-selection--single {
        height: 32px;
        border-color: #{$form-border};
        border-radius: 3px;

        .select2-selection__rendered {
          line-height: 32px;
        }

        .select2-selection__arrow {
          height: 30px;

          b {
            border-block-start-color: #{$gray-500};
          }
        }
      }
    }
  }

  .dataTables_filter {
    text-align: start;

    label {
      display: block;
      margin-block-end: 15px;
    }

    input {
      margin-inline-start: 0;
      border: 1px solid #{$primary-03};
      padding: 16px 10px;
      line-height: 1.539;
      color: #{$default-color};
      border-radius: 3px;
      width: 100%;

      &::placeholder {
        color: #{$gray-500};
      }
      &:focus {
        border: 1px solid #{$primary-05};
      }
    }
  }

  .dataTables_info {
    margin-block-start: 19px !important;
    padding: 0 !important;
    text-align: start;
  }

  .dataTables_paginate {
    margin-block-start: 15px !important;
    padding-block-start: 0;
    margin-block-start: 15px;
    text-align: start;

    .paginate_button {
      background-color: transparent;
      padding: 0;
      margin: 0;
      border: 0;
      border-radius: 1px;
      transition: all 0.2s ease-in-out;

      +.paginate_button {
        margin-inline-start: 0px;
      }

      &.disabled {
        background-color: transparent;
        color: #{$gray-300}  !important;

        &:hover,
        &:focus {
          color: #{$gray-300}  !important;
        }
      }

      &:hover,
      &:focus {
        border: 0;
        background-image: none;
        background-color: transparent;
        color: #{$default-color}  !important;
      }

      &.current {
        border: 0;
        background-image: none;
        background-color: #{$primary};
        color: rgb($white)   !important;

        &:hover,
        &:focus {
          border: 0;
          background-image: none;
          background-color: #{$primary};
          color: rgb($white)   !important;
        }
      }
    }
  }
}

@media (min-width: 576px) {
  .dataTables_wrapper .dataTables_filter {
    float: $float-end;
    margin-block-start: 0;
  }
}

@media (min-width: 576px) {
  .dataTables_wrapper .dataTables_filter input {
    width: auto;
  }
}

@media (min-width: 576px) {
  .dataTables_wrapper .dataTables_info {
    float: $float-start;
  }
}

@media (min-width: 576px) {
  .dataTables_wrapper .dataTables_paginate {
    float: $float-end;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dataTables_wrapper .dataTables_paginate .paginate_button {
    transition: none;
  }
}

@media (max-width: 575px) {
  .dataTables_wrapper .dataTables_length .select2-container--default {
    margin-block-end: 15px;
  }
}

.table.dataTable thead .sorting:before {
  display: none;
}

table.dataTable thead {

  .sorting_asc:before,
  .sorting_desc:before,
  .sorting_asc_disabled:before,
  .sorting_desc_disabled:before {
    display: none;
  }
}

.dataTables_paginate {
  .pagination .page-link {
    padding: 0.5rem 0.75rem;
    background-color: #{$bg-white};
    border: 1px solid #{$primary-03};
    width: auto;
  }

  .page-item.active .page-link {
    background-color: #{$primary};
  }
}

.dataTables_wrapper .dataTables_paginate {
  .paginate_button.focus {
    background: #{$primary};
  }

  .page-item.disabled .page-link {
    // background-color: rgb($white);
    color: #{$default-color};
    font-size: 12px;
  }
}

.page-item.next a {
  width: 64px;
}

table.dataTable tfoot {

  th,
  td {
    padding-block-start: 10px;
    padding-inline: 18px;
    padding-block-end: 6px;
    border-block-start: 1px solid #{$gray-200};
  }
}

.table-responsive.hoverable-table {
  position: relative;
}

.hoverable-table .btn-primary {
  position: absolute;
  margin-inline-start: 98px;
  inset-block-start: 0px;
  padding: 7px 16px;
  z-index: 99;
}

#basic-datatable,
#responsive-datatable,
#delete-datatable,
#file-datatable {
  .select2.select2-container.select2-container--default.select2-container--below.select2-container--focus {
    width: 100% !important;
  }
}

#example1 {
  .select2.select2-container.select2-container--default.select2-container--below.select2-container--focus {
    width: auto !important;
  }
}

@media (max-width: 767px) {
  .table-responsive.deleted-table .data-table-btn {
    position: absolute;
    inset-inline-start: 100px;
    z-index: 9;
  }
}

@media screen and (max-width: 500px) {
  .dataTables_paginate .pagination .page-link {
    padding: 0.5rem 0.3rem;
  }
}