@use 'sass:color';
@use '../theme.scss' as *;

.be-pagination {
  display: flex;
  width: 100%;
  outline: 0;
  align-items: center;
  &.hide {
    display: none;
  }
  &.round {
    .pagination-nav,
    .pagination-num {
      border-radius: 17px;
    }
  }
  &.border {
    .pagination-nav,
    .pagination-num {
      border: 1px solid var(--brd);
    }
  }
  .pagination {
    &-item {
      font-size: 1rem;
      border: 1px solid;
      background-color: #fff;
      border-color: #d5d5d5;
    }
    &-page-wrapper {
      display: flex;
    }
    &-nav,
    &-num {
      cursor: pointer;
      display: inline-flex;
      justify-content: center;
      align-items: center;
      min-width: 2em;
      line-height: 1em;
      text-align: center;
      font-weight: 500;
      vertical-align: baseline;
      margin: 0 2px;
      padding: 0.5em;
      user-select: none;
      color: #909090;
      border-radius: 4px;
      // transition-duration: 0.1s;
      // transition: all 250ms ease;
      &:hover {
        background-color: #ccc;
        border-color: #f8f8f8;
        color: #fff;
      }
      &.active {
        background-color: $primary;
        border-color: color.adjust($primary, $lightness: -10%);
        color: #fff;
        pointer-events: none;
      }
      &.disabled {
        pointer-events: none;
        opacity: 0.5;
      }
    }
  }
  &.be-flex,
  &.align {
    &-left {
      justify-content: flex-start;
    }
    &-center {
      justify-content: center;
    }
    &-right {
      justify-content: flex-end;
    }
  }
  &.page {
    .pagination {
      &-info {
        font-size: 14px;
        background-color: #fff;
        line-height: 1em;
        text-align: center;
        font-weight: 500;
        user-select: none;
        color: #909090;
        pointer-events: none;
      }

      &-nav {
        margin: 0;
        border-radius: 0;
        z-index: 10;
        &:first-child {
          margin-right: -1px;
        }

        &:last-child {
          margin-left: -1px;
        }
      }
    }
    //&.round {
    //  .pagination-nav {
    //    &:first-child {
    //      border-bottom-left-radius: 17px;
    //      border-top-left-radius: 17px;
    //    }
    //
    //    &:last-child {
    //      border-bottom-right-radius: 17px;a
    //      border-top-right-radius: 17px;
    //    }
    //  }
    //}
  }
  &.compact {
    .pagination {
      &-page-wrapper {
        //padding: 6px 8px;
        //border: 1px solid #d6d6d6;
      }
      &-num,
      &-nav {
        min-width: 1.75em;
        line-height: 0.75em;
        padding: 0.375em;
        margin: 0 3px;
      }
    }
  }
  &.text {
    .pagination {
      &-num,
      &-nav {
        border-color: transparent;
        background-color: transparent;
        &:hover {
          color: #ccc;
        }
        &.active {
          font-weight: 800;
          color: $primary;
          pointer-events: none;
        }
      }
    }
  }
}

@each $color, $value in $colors {
  $hoverColor: color.adjust($value, $lightness: -10%);
  $textColor: $white;
  @if color-contrast($value, $textColor) < 1.8 {
    $textColor: $black;
  }
  .be-pagination {
    background-color: transparent;
    &.#{$color} {
      .pagination-num.active {
        background-color: $value;
      }
    }
    &.text.#{$color} {
      .pagination-num.active {
        background-color: transparent;
        color: $value;
      }
    }
  }
}
