@import '../style/theme/color';
@import '../style/theme/shadow';
@import '../style/theme/corner';
@import '../style/core/_font';
@import '../style/core/animation';
@import '../style/theme/z-index';

:host {
  display: block;
}

.devui-pagination {
  display: flex;
  align-items: center;

  .devui-page-size {
    display: inline-block;
    vertical-align: middle;
    margin: 0 8px 0 0;
    position: relative;
    height: 28px;

    &.devui-page-size-sm {
      height: 26px;
    }

    &.devui-page-size-lg {
      height: 46px;

      li a.devui-pagination-link {
        height: 46px;
        line-height: 46px;
      }
    }
  }

  .devui-per-page {
    margin-right: 8px;
    color: $devui-text-weak;
  }

  .devui-total-size {
    display: inline-block;
    position: relative;
    margin: 0 12px 0 0;
    color: $devui-text-weak;
  }

  .devui-pagination-list {
    vertical-align: middle;
    display: inline-flex;
    align-items: center;

    > .disabled > a,
    > .disabled > a:hover,
    > .disabled > a:focus {
      cursor: not-allowed;
    }

    li {
      display: inline;
    }

    li.disabled a {
      color: $devui-disabled-text;

      svg g polygon {
        fill: $devui-disabled-text;
      }
    }

    li.disabled:first-child a,
    li.disabled:last-child a {
      border-color: $devui-disabled-line;
    }

    li:not(.disabled) {
      cursor: pointer;

      a:hover,
      span:hover,
      a:focus,
      span:focus {
        background-color: $devui-base-bg;
        color: $devui-list-item-hover-text;
        text-decoration: none; // 覆盖bootStrap默认样式
      }

      a:active {
        background-color: $devui-list-item-active-bg;
        color: $devui-list-item-active-text;
      }

      &.active a {
        color: $devui-list-item-active-text;
        cursor: pointer;

        &:hover {
          background-color: transparent;
          color: $devui-list-item-active-text;
        }
      }

      a.devui-pagination-link:hover:not(:active) svg g polygon {
        fill: $devui-icon-fill-active-hover;
      }

      a.devui-pagination-link:active svg g polygon {
        fill: $devui-light-text;
      }
    }

    .devui-pagination-link {
      svg {
        vertical-align: middle;

        g polygon {
          fill: $devui-icon-text;
        }
      }
    }

    .devui-pagination-link-lite {
      border: 1px solid transparent !important;
      border-radius: $devui-border-radius;
    }
  }

  .devui-pagination-list > li > a {
    margin-left: 4px;
    padding: 0 8px;
    line-height: 24px;
    border-radius: $devui-border-radius;
    color: $devui-text-weak;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .devui-pagination-sm > li > a {
    padding: 0 4px;
    min-width: 18px;
    line-height: 22px;
    font-size: $devui-font-size-sm;
  }

  .devui-pagination-lg > li > a {
    padding: 0 12px;
    font-size: $devui-font-size-lg;
    line-height: 38px;
  }

  .devui-pagination-list > li:first-child > a,
  .devui-pagination-list > li:last-child > a {
    min-width: 34px;
    height: 32px;
    line-height: 32px;
    padding: 0 8px;
  }

  .devui-pagination-sm > li:first-child > a,
  .devui-pagination-sm > li:last-child > a {
    border-radius: $devui-border-radius;
    min-width: 20px;
    height: 30px;
    line-height: 30px;
    padding: 0 4px;
  }

  .devui-pagination-lg > li:first-child > a,
  .devui-pagination-lg > li:last-child > a {
    border-radius: $devui-border-radius;
    min-width: 46px;
    height: 46px;
    line-height: 46px;
    padding: 0 16px;
  }

  .devui-jump-container {
    display: inline-flex;
    position: relative;
    margin: 0 12px 0 12px;
    vertical-align: middle;
    align-items: center;

    .devui-input {
      display: inline-block;
      width: 3.5em;
      vertical-align: middle;
      margin: 0 4px;
    }
  }

  .devui-jump-button {
    display: inline-flex;
    vertical-align: middle;
    border-radius: $devui-border-radius;
    border: 1px solid $devui-line;
    cursor: pointer;
    margin-left: 4px;
    align-items: center;
    justify-content: center;

    .devui-pagination-go {
      width: 0;
      height: 0;
      border-top-style: solid;
      border-left-style: solid;
      border-bottom-style: solid;
    }

    &:hover {
      border-color: $devui-brand-active;

      .devui-pagination-go {
        border-left-color: $devui-brand-active;
      }
    }
  }

  .devui-jump-size-default {
    width: 34px;
    height: 34px;

    .devui-pagination-go {
      width: 0;
      height: 0;
      border-top: 12px solid transparent;
      border-left: 12px solid $devui-icon-text;
      border-bottom: 12px solid transparent;
    }
  }

  .devui-jump-size-sm {
    width: 24px;
    height: 24px;

    .devui-pagination-go {
      width: 0;
      height: 0;
      border-top: 6px solid transparent;
      border-left: 6px solid $devui-icon-text;
      border-bottom: 6px solid transparent;
    }

    .devui-pagination-link {
      height: 30px;
      line-height: 32px;
    }
  }

  .devui-jump-size-lg {
    width: 46px;
    height: 46px;

    .devui-pagination-go {
      width: 0;
      height: 0;
      border-top: 16px solid transparent;
      border-left: 16px solid $devui-icon-text;
      border-bottom: 16px solid transparent;
    }
  }

  .devui-lite-paginator {
    display: inline-block;
    margin-right: 4px;
    width: 100px;
    vertical-align: middle;
  }

  .devui-pagination-config {
    color: $devui-text;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin: 0 4px;

    .devui-setup-icon {
      line-height: 30px;
      cursor: pointer;
      display: flex;

      svg g path {
        fill: $devui-icon-text;
      }
    }

    .devui-config-container {
      padding: 4px 0;
      box-shadow: $devui-shadow-length-connected-overlay $devui-shadow;
      border-radius: $devui-border-radius;
      width: 150px;
      background-color: $devui-connected-overlay-bg;
      line-height: 26px;
      position: absolute;
      left: -136px;
      top: 28px;
      cursor: auto;
      z-index: $devui-z-index-dropdown;
      -moz-user-select: none;
      -webkit-user-select: none;
      -ms-user-select: none;
      user-select: none;

      .devui-pagination-config-item.devui-page-size-config {
        border-bottom: none;
      }

      .devui-pagination-config-item {
        padding-bottom: 8px;
        padding-top: 4px;
        border-bottom: 1px solid $devui-dividing-line;

        .devui-config-item-title {
          color: $devui-aide-text;
          padding-left: 8px;
          font-size: $devui-font-size;
          line-height: 22px;
        }

        .devui-page-number {
          padding-left: 8px;
          margin-top: 4px;
          display: flex;
          display: -ms-flexbox;

          div {
            color: $devui-text;
            cursor: pointer;
            border-top: 1px solid $devui-line;
            border-bottom: 1px solid $devui-line;
            border-right: 1px solid $devui-line;
            text-align: center;
            height: 26px;
            width: 26px;
          }

          div:hover {
            background-color: $devui-list-item-hover-bg;
            color: $devui-list-item-hover-text;
          }

          div:first-child {
            border-left: 1px solid $devui-line;
          }

          .devui-page-number div.choosed,
          .choosed {
            &:not(:hover):not(:active) {
              color: $devui-list-item-active-text;
              background-color: $devui-list-item-active-bg !important;
              cursor: auto !important;
            }
          }
        }
      }
    }
  }
}

.devui-pagination {
  .devui-pagination-list {
    li {
      a {
        transition: background-color $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;
      }
    }
  }
}

.devui-pagination-hidden {
  display: none;
}

:host ::ng-deep .devui-input-sm {
  height: 24px;
  padding: 4px 4px;
  font-size: $devui-font-size;
  line-height: 1.5;
  border-radius: $devui-border-radius;
}

:host ::ng-deep .devui-input-lg {
  height: 46px;
}

.devui-pagination-dropdown-menu {
  min-width: 60px;
}

.devui-pagination-list > li > .devui-pagination-active-block {
  height: 24px;
  margin-bottom: -24px;
}

.devui-pagination-sm > li > .devui-pagination-active-block {
  height: 22px;
  margin-bottom: -22px;
}

.devui-pagination-lg > li > .devui-pagination-active-block {
  height: 38px;
  margin-bottom: -38px;
}

.devui-pagination-active-block {
  width: calc(100% - 4px);
  margin-bottom: -24px;
  margin-left: 4px;
  background: $devui-primary;
  z-index: 0;
  border-radius: $devui-border-radius;
}

.devui-pagination-acitve-item {
  background: $devui-list-item-active-bg;
}
