@import './constants.scss';
@import './loader.scss';

.pk-table {
  position: relative;
  clear: both;
  overflow: hidden;
  border: 1px solid $border-color;

  &-body {
    width: auto;
    background-color: #ffffff;
    overflow-x: auto;
    overflow-y: scroll;
  }

  &-row {
    width: auto;
    display: flex;
    flex: 1 0 auto;

    &-cell {
      padding: 0px 16px;
      display: flex;
      align-items: center;
      flex: 1 0 0;
      background-color: #ffffff;

      .pk-table-content {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      &.selection-column {
        padding: 0px;

        .selection-column-icon {
          width: 100%;
          height: 100%;
          color: #5d5d5d !important;

          &:hover {
            color: $primary !important;
          }
        }
      }
    }

    &.pk-table-row-selected {
      .pk-table-row-cell {
        background-color: $selected-color !important;
      }
    }

    &.pk-table-row-header {
      position: sticky;
      top: 0;
      left: 0;
      z-index: 2;
      font-weight: 600;
      border-bottom: 1px solid $border-color;

      .pk-table-row-cell {
        background-color: $header-bg;
        color: $primary;
        justify-content: space-between;
      }
    }

    &:not(.pk-table-row-header) {
      .pk-table-icon {
        animation: fade-in 0.1s ease-in-out;
      }
    }
  }

  &-footer {
    background-color: #ffffff;
    border-top: 1px solid $border-color;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;

    @media screen and (max-width: 576px) {
      font-size: 12px;
      padding: 0 8px;
    }

    .pk-table-page-info {
      display: flex;
      align-items: center;

      .pk-dropdown {
        margin: 0 16px;

        @media screen and (max-width: 576px) {
          margin: 0 8px;
        }
      }
    }
  }

  .pk-table-fixed-column {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: #ffffff;
    border-right: 1px solid $border-color;

    &.fixed-right {
      right: 0;
    }
  }

  &-pagination {
    display: flex;
    align-items: center;
    margin-right: 16px;

    @media screen and (max-width: 576px) {
      margin-right: 8px;
    }

    &-item {
      display: flex;
      justify-content: center;
      align-items: center;

      &:not(:last-child) {
        margin-right: 16px;

        @media screen and (max-width: 576px) {
          margin-right: 8px;
        }
      }
    }

    .pk-pager-icon {
      margin: 0 8px;

      @media screen and (max-width: 576px) {
        margin: 0 4px;
      }
    }

    .pk-pager-disabled {
      opacity: 0.4;
      pointer-events: none;
    }
  }

  &-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;

    &.pk-icon-large {
      width: 28px;
      height: 28px;
    }
  }

  &-column-settings {
    position: absolute;
    overflow-x: hidden;
    overflow-y: auto;
    right: 2px;
    width: 240px;
    background-color: #fff;
    box-shadow: 0px 0px 4px 1px rgba(0, 0, 0, 0.15);
    z-index: 2;
    transform-origin: top right;
    animation: scale-in 0.25s cubic-bezier(0.075, 0.82, 0.165, 1);

    ul {
      list-style: none;
      padding: 12px 8px;
      margin: 0px;

      li {
        display: flex;
        align-items: center;
        height: 32px;
        line-height: 32px;
        padding: 0 8px;
        margin-bottom: 4px;
        cursor: pointer;

        &.settings-disabled {
          opacity: .35;
          cursor: not-allowed;
          pointer-events: none;
        }

        &:hover {
          background-color: rgba($color: #000000, $alpha: .05);
        }

        .column-settings-icon {
          margin-right: 16px;
        }
      }
    }

    &--header {
      padding: 12px 12px;
      position: sticky;
      top: 0;
      z-index: 1;
      background-color: #fff;
      box-shadow: 0 0 4px 1px rgba($color: #000000, $alpha: .15);
    }
  }

  .icon-clickable {
    cursor: pointer;

    &:hover {
      background-color: $hover-color;
    }
  }

  .hide-sm {
    @media screen and (max-width: 575px) {
      display: none;
    }
  }

  .display-sm {
    @media screen and (min-width: 576px) {
      display: none;
    }
  }

  .hide-md {
    @media screen and (max-width: 767px) {
      display: none;
    }
  }

  .display-md {
    @media screen and (min-width: 768px) {
      display: none;
    }
  }
}

.pk-table-bordered {
  .pk-table-row {
    border-bottom: 1px solid $border-color;
  }
}

.pk-table-bordered,
.pk-table-borderless {
  .pk-table-row:not(.pk-table-row-selected):not(.pk-table-row-header) {
    &:hover {
      .pk-table-row-cell {
        background-color: $hover-color;
      }
    }
  }
}

.pk-table-striped {
  .pk-table-row {
    &:not(.pk-table-row-header) {
      &:nth-of-type(odd) {
        .pk-table-row-cell {
          background-color: $hover-color;
        }
      }
    }
  }
}

.pk-table-icon {
  fill: $primary;

  &:hover {
    fill: $primary-dark;
  }
}

.cursor-pointer {
  cursor: pointer;
}

.pk-dropdown {
  position: relative;
  height: 28px;

  &-input {
    width: 100%;
    height: 100%;
    padding: 0 8px;
    display: flex;
    align-items: center;
    border-radius: 2px;

    &:hover {
      background-color: rgba($color: #000000, $alpha: .05);
    }
  }

  &-container {
    list-style: none;
    margin: 0;
    padding: 0;

    display: none;
    
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    background-color: #ffffff;
    border: 1px solid $border-color;
    border-radius: 2px;
    z-index: 1000;

    &.open {
      display: block;

      animation: drop-up 0.2s ease-in-out;
    }
  }

  &-item {
    padding: 6px 8px;
    display: flex;
    align-items: center;

    &:hover {
      background-color: rgba($color: #000000, $alpha: .05);
    }

    &.active {
      color: $primary;
    }
  }
}

.pk-table-empty,
.pk-table-loader-container {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9;
  animation: fade-in .4s ease-in-out;
}

.pk-table-empty {
  background-color: #ffffff;
  flex-direction: column;
}

.d-flex-justify-center-align-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.border-left {
  border-left: 1px solid $border-color;
}

@keyframes scale-in {
  from {
    transform: scale(0, 0);
    opacity: 0;
  }
  to {
    transform: scale(1, 1);
    opacity: 1;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes drop-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0px);
    opacity: 1;
  }
}
