.table-card {
  padding: 16px;
  @include respond(phone) {
    min-width: 100%;
    background: $white;
    border: 1px solid $light-grey;
    border-radius: 8px;
    box-shadow: $card-shadow;
    padding: 0;
  }
  @include respond(tab-port) {
    overflow-x: auto;
  }
  p {
    margin-bottom: 0;
  }
}

.table-topbar-container {
  @include display-flex(space-between, center);
  margin-bottom: 16px;

  .table-topbar-info {
    @include display-flex(flex-start, center);

    h4 {
      margin-right: 16px;
    }
  }

  .table-topbar-actions {
    @include display-flex(flex-start, center);
    position: relative;

    &__search {
      @include display-flex(flex-end, center);

      .input-container {
        min-width: auto;
        width: 50px;
        transition: all ease-in-out 0.3s;
        cursor: pointer;

        .input-display {
          height: 32px;
          background: $light;
          transition: all ease-in-out 0.3s;
          overflow: hidden;

          .input-addon {
            border: 0;
          }

          .table-search-close {
            opacity: 0;
            transition: all ease-in-out 0.3s;
          }

          input {
            @include placeholder(32px);
          }
        }
      }

      &.open {
        .input-container {
          width: 100%;
          cursor: unset;

          .input-display {
            background: $white;

            .table-search-close {
              opacity: 1;
            }
          }
        }
      }
    }

    & > * {
      margin-right: 8px;
      min-width: unset;
    }

    // .export-button-container {
    // position: unset;
    // }

    .tabletop-button {
      @include display-flex(flex-start, flex-start);
      cursor: pointer;
      width: 16px;
      svg {
        path {
          fill: $dark-grey;
        }
      }
    }
  }
  @include respond(tab-port) {
    margin: 16px;
    .table-topbar-actions {
      display: none !important;
    }
    .icon-button div:first-of-type {
      margin-right: 0 !important;
    }
  }
}

.table-filter-container {
  background: $light;
  margin: 0 -16px 16px;
  height: 0;
  max-height: 0;
  overflow: hidden;
  transition: all ease-in-out 0.3s;

  .table-filter-header {
    @include display-flex(space-between, center);
    padding: 16px;
    border-bottom: 1px solid $light-grey;
    opacity: 0;
    transition: all ease-in-out 0.3s;

    & > div {
      @include display-flex(flex-start, center);
    }

    &__close {
      @include display-flex(flex-start, flex-start);
      width: 16px;
      cursor: pointer;
      margin-left: 16px;
    }
  }

  .table-filter-content {
    @include display-grid(4, 16px);
    padding: 16px;
    opacity: 0;
    transition: opacity ease-in-out 0.3s;
  }

  &.active {
    height: auto;
    max-height: 250px;
    overflow: unset;
    transition: all ease-in-out 0.3s;

    .table-filter-header,
    .table-filter-content {
      opacity: 1;
      transition: opacity 0.3s ease-in-out 0.3s;
    }
  }
  @include respond(phone) {
    margin: 0;
  }
}

.table-customize-cols {
  .okra-popup__body {
    padding: 0 24px;
    @include display-flex(flex-start, flex-start);
  }

  .table-edit-col-container,
  .table-your-col-container {
    padding: 24px 0 16px;

    p {
      max-width: 380px;
    }

    .table-edit-col,
    .table-your-col {
      margin-top: 16px;
    }
  }

  .table-edit-col-container {
    width: 100%;
    padding-right: 16px;
    border-right: 1px solid $light-grey;

    .table-edit-col {
      &__item {
        height: 40px;
        @include display-flex(flex-start, center);

        .checkbox-container {
          .checkbox-label {
            margin-left: 16px;
          }
        }
      }
    }
  }

  .table-your-col-container {
    width: 290px;
    flex: 0 0 290px;
    padding-left: 16px;

    .table-your-col {
      margin: 16px -16px 0;

      &__item {
        background: $white;
        @include display-flex(space-between, center);
        padding: 0 16px;
        transition: all ease-in-out 0.3s;
        cursor: move;
        opacity: 0;
        height: 0;

        & > div {
          @include display-flex(flex-start, center);
        }

        &-icon {
          @include display-flex(flex-start, flex-start);
          width: 16px;
          margin-right: 16px;
        }

        &-remove {
          cursor: pointer;
          width: 16px;
          align-items: flex-start;
        }

        &.checked {
          opacity: 1;
          height: 40px;
        }
      }
    }
  }
}

.table-container {
  border: 1px solid $light-grey;
  border-radius: 8px;
  background: $white;
  overflow-x: auto;

  table {
    border: 0;
    border-spacing: 0;
    width: 100%;

    tr {
      th,
      td {
        line-height: 18px;
        transition: all ease-in-out 0.3s;

        &.table-checkbox {
          width: 20px;
        }

        &:first-child {
          padding-left: 24px;
        }

        &:last-child {
          padding-right: 24px;
          text-align: right;
          white-space: nowrap;
        }
      }

      th {
        color: $black;
        font-size: 12px;
        line-height: 18px;
        font-weight: 600;
        text-transform: uppercase;
        text-align: left;
        padding: 14px 8px;
      }

      td {
        padding: 24px 8px;
        font-size: 14px;
        font-weight: 500;
        color: $black;
        letter-spacing: -0.006px;
        border-top: 1px solid $light-grey;
        vertical-align: middle;
        position: relative;

        .td-render {
          transition: all ease-in-out 0.3s;
        }

        .tr-action {
          @include display-flex(flex-end, center);
          position: absolute;
          opacity: 0;
          transition: all ease-in-out 0.3s;
          pointer-events: none;
          right: 24px;
          top: calc(50% - 12px);
        }
      }

      &:hover,
      &.selected {
        td {
          background: $light;

          &:last-child {
            .td-render {
              opacity: 0;

              &.no-action {
                opacity: 1;
              }
            }

            .tr-action {
              opacity: 1;
              pointer-events: all;
            }
          }
        }
      }
      &.clickable {
        cursor: pointer;
        &.active {
          background: $light;
        }
      }
    }
  }
  @include respond(phone) {
    border: none;
    border-radius: 0;
    background: transparent;
    .table-checkbox {
      display: none;
    }
    thead {
      display: none;
    }
    tr {
      display: block;
      padding: 24px 16px;
      border-top: 1px solid $light-grey;
      &:hover,
      &.selected {
        td {
          background: none !important;
        }
      }
    }
    td {
      display: block;
      text-align: left;
      border-top: none !important;
      padding: 0 !important;
      &:not(:last-child) {
        padding-bottom: 12px !important;
      }
      &:last-child {
        text-align: left !important;
        .td-render {
          opacity: 1 !important;
        }
      }
      .tr-action {
        pointer-events: all !important;
        opacity: 1 !important;
        position: unset !important;
        justify-content: space-between !important;
        margin-top: 10px;
      }
    }
  }

  .table-empty-state {
    height: 500px;
    max-width: 500px;
    margin: auto;
    @include display-flex(center, center, column);
    text-align: center;

    span {
      display: flex;
      white-space: normal;
    }

    &__icon {
      width: 30px;

      svg {
        width: 100%;
        height: auto;
      }
    }

    &__title {
      margin: 8px 0;
    }
  }
}

.table-pagination-container {
  padding: 16px 0 !important;
  @include display-flex(space-between, center);
  &.inverse {
    flex-direction: row-reverse;
  }
}

.table-pagination-rows,
.table-pagination-pages {
  @include display-flex(flex-start, center);

  &__text {
    color: $dark-grey;
  }

  .select-container {
    min-width: 56px;
    width: 56px;
    margin-left: 6px;

    .select-display {
      background: transparent;
      border: 0;
      padding: 0 10px;
      height: auto;

      &__text {
        color: $dark-grey;
      }

      &__dropdown {
        padding: 0 0 0 5px;

        svg {
          width: 10px;

          path {
            fill: $dark-grey;
          }
        }
      }
    }

    &__focused {
      .select-display {
        box-shadow: none;
      }
    }
  }
}
.table-pagination-rows {
  @include respond(phone) {
    display: none;
  }
}
.table-pagination-pages {
  &__nav {
    margin-left: 50px;
    @include display-flex(flex-start, center);

    span {
      @include display-flex(flex-start, center);
      cursor: pointer;

      &:first-child {
        margin-right: 35px;
      }

      svg {
        g,
        path {
          transition: all ease-in-out 0.3s;
        }
      }
      svg {
        g,
        path {
          stroke: black;
        }
      }
      &.disabled {
        pointer-events: none;

        svg {
          g,
          path {
            stroke: $grey;
          }
        }
      }
    }
  }
  @include respond(phone) {
    padding: 12px;
    flex: 1;
    justify-content: space-between;
  }
}

.loader-container {
  width: 100%;
  @include display-flex(center, center, column);

  p {
    margin-top: 12px;
    color: $dark-blue-6;
  }

  .loader {
    width: 32px;
    height: 32px;
    border: 3px solid transparent;
    border-bottom-color: $primary;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
  }

  @keyframes rotation {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
