@import '../styles/themes/themes.less';

@tab-color: @default-color;
@tab-border: @disable-color;
@tab-active: @primary-color;
@tab-header-bg: #FAFBFD;
@tab-white: @white-color;
@tab-gray: @light-gray;
@tab-number-tag-gray: @gray-color;
@tab-card-number-active: #E1ECFF;
@tab-column-active: #A3C5FD;
@tab-card-tab-bg: #F0F1F5;
@tab-card-tab-divider: #c4c6cc;
@tab-disable-color: #aaa;

.@{bk-prefix}-tab {
  position: relative;
  display: flex;

  &--top {
    flex-direction: column;
  }


  &--right {
    flex-direction: row-reverse;
  }

  &-header {
    position: relative;
    display: flex;
    color: @tab-color;

    .@{bk-prefix}-tab--left & {
      border-right: 1px solid @tab-border;
    }

    .@{bk-prefix}-tab--right & {
      border-left: 1px solid @tab-border;
    }

    .@{bk-prefix}-tab--vertical-tab & {
      border: 0;
    }

    .@{bk-prefix}-tab--left &, .@{bk-prefix}-tab--right & {
      flex-direction: column;
      .@{bk-prefix}-tab-header-item {
        .@{bk-prefix}-tab-header--has-num {
          width: 100%;
          &-right {
            .@{bk-prefix}-tab-header--has-num-square {
              border-radius: 2px;
            }
          }
        }
      }
      .@{bk-prefix}-tab-header--active {
        .@{bk-prefix}-tab-header--has-num {
          &-right {
            .@{bk-prefix}-tab-header--has-num-square,
            .@{bk-prefix}-tab-header--has-num-elliptic {
              background-color: @tab-column-active;
              color: @tab-white;
            }
          }
        }
      }
      
      > div {
        flex-direction: column;
      }
    }

    .@{bk-prefix}-tab--card-tab &, .@{bk-prefix}-tab--vertical-tab & {
      background: @tab-card-tab-bg;
    }

    .@{bk-prefix}-tab--card-tab & {
      border-radius: 4px 4px 0;
      .@{bk-prefix}-tab-header-item {
        .@{bk-prefix}-tab-header--has-num {
          &-right {
            .@{bk-prefix}-tab-header--has-num-square {
              background-color: @tab-white;
            }
            .@{bk-prefix}-tab-header--has-num-elliptic {
              background-color: @tab-white;
              color: @tab-color;
            }
          }
        }
      }
      .@{bk-prefix}-tab-header--active {
        .@{bk-prefix}-tab-header--has-num {
          &-right {
            .@{bk-prefix}-tab-header--has-num-square,
            .@{bk-prefix}-tab-header--has-num-elliptic {
              background-color: @tab-column-active;
              color: @tab-white;
            }
          }
        }
      }
    }

    .@{bk-prefix}-tab--card &, .@{bk-prefix}-tab--vertical-card & {
      border-bottom: 1px solid @tab-border;
    }

    .@{bk-prefix}-tab--border-card & {
      border: solid @tab-border;
      border-width: 1px 1px 1px 0;
    }

    .@{bk-prefix}-tab--border-card & {
      background: @tab-header-bg;
    }

    .@{bk-prefix}-tab--unborder-card & {
      border-bottom: 1px solid @tab-border;
    }


    > div {
      display: flex;
      flex-wrap: nowrap;
      .@{bk-prefix}-tab--card &, .@{bk-prefix}-tab--vertical-card & ,.@{bk-prefix}-tab--border-card & {
        margin-bottom: -1px;
      }
    }

    &-nav {
      position: relative;
      //width: 100%;

      .@{bk-prefix}-tab--top & {
        overflow-x: auto;
        overflow-y: visible;
      }

      .@{bk-prefix}-tab--left &, .@{bk-prefix}-tab--right & {
        overflow-x: visible;
        overflow-y: auto;
      }


      .@{bk-prefix}-tab--card &, .@{bk-prefix}-tab--border-card &, .@{bk-prefix}-tab--vertical-card & {
        border-left: 1px solid @tab-border;
      }

      &::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
      }
    }

    &-next,
    &-prev {
      position: absolute;
      top: 1px;
      bottom: 1px;
      width: 15px;
      background: #fff;
      content: '';
    }

    &-prev {
      left: 1px;
    }

    &-next {
      right: 1px;
    }

    &-operation {
      //flex: 0 0 auto;
      .@{bk-prefix}-tab-header-item {
        padding: 0 12px;
      }
    }

    &-setting {
      justify-self: flex-end;
      margin-left: auto;
      white-space: nowrap;
    }


    &-item {
      display: flex;
      white-space: nowrap;
      cursor: pointer;
      justify-content: center;
      align-items: center;

      .@{bk-prefix}-tab--top & {
        padding: 0 20px;
      }

      .@{bk-prefix}-tab--left &, .@{bk-prefix}-tab--right & {
        padding: 0 12px;
      }

      .@{bk-prefix}-tab--left & {
        text-align: right;
      }

      .@{bk-prefix}-tab--card &, .@{bk-prefix}-tab--vertical-card & {
        border-top: 1px solid @tab-border;
      }

      .@{bk-prefix}-tab--card &, .@{bk-prefix}-tab--border-card &, .@{bk-prefix}-tab--vertical-card & {
        border-right: 1px solid @tab-border;

        //&:last-of-type {
        //  border-right: none;
        //}
      }

      .@{bk-prefix}-tab--card-tab & {
        position: relative;

        &:not(:first-of-type):before,
        &:last-of-type:after {
          position: absolute;
          top: 50%;
          left: 0;
          display: block;
          width: 1px;
          height: 16px;
          margin-top: -8px;
          background: @tab-card-tab-divider;
          content: '';
        }

        &:last-of-type:after {
          right: 0;
          left: initial;
        }


      }

      .@{bk-prefix}-tab--card-grid & {
        height: 40px;
        margin-right: 8px;
        line-height: 40px;
        background: #eaebf0;
        border-radius: 4px 4px 0 0;
      }

      .@{bk-prefix}-tab-header-operation & {
        padding-right: 12px;
        padding-left: 12px;
      }

      .@{bk-prefix}-tab-header--has-num {
        display: flex;
        align-items: center;
        justify-content: space-between;
        &-right {
          margin-left: 4px;
          display: flex;
          align-items: center;
          color: @tab-color;
          .@{bk-prefix}-tab-header--has-num-default,
          .@{bk-prefix}-tab-header--has-num-bracket {
            color: @tab-color;
          }
          .@{bk-prefix}-tab-header--has-num-square,
          .@{bk-prefix}-tab-header--has-num-elliptic {
            background-color: @tab-card-tab-bg;
            color: @tab-number-tag-gray;
            padding: 0 8px;
            line-height: 18px;
            text-align: center;
          }
          .@{bk-prefix}-tab-header--has-num-square {
            border-radius: 2px;
          }
          .@{bk-prefix}-tab-header--has-num-elliptic {
            border-radius: 18px;
          }
        }
      }
      
      &:hover {
        color: @tab-active;

        .@{bk-prefix}-tab-header--close {
          display: block;
          margin-left: 5px;
          color: @danger-color;
        }
      }
    }

    &--active {
      color: @tab-active;

      .@{bk-prefix}-tab--card &, .@{bk-prefix}-tab--border-card &, .@{bk-prefix}-tab--vertical-card & {
        background: @tab-white;
        border-bottom-color: @tab-white;
      }


      .@{bk-prefix}-tab--card-tab &, .@{bk-prefix}-tab--vertical-tab & {
        background: #fff;
      }

      .@{bk-prefix}-tab--card-tab & {
        border-radius: 4px 4px 0 0;

        &:after, &:before, & + .@{bk-prefix}-tab-header-item:before {
          /* stylelint-disable-next-line declaration-no-important */
          display: none !important;
        }

      }

      .@{bk-prefix}-tab--card-grid & {
        background: #fff;
      }

      /* 激活边框，跟随，不再用固定样式
      //.@{bk-prefix}-tab--unborder-card & {
      //  border-bottom: 2px solid @tab-active;
      //}
      .@{bk-prefix}-tab--left:not(.@{bk-prefix}-tab--vertical-tab) & {
        border-right: 2px solid @tab-active;
      }

      .@{bk-prefix}-tab--right:not(.@{bk-prefix}-tab--vertical-tab) & {
        border-left: 2px solid @tab-active;
      }
      */
      .@{bk-prefix}-tab-header--has-num {
        &-right {
          .@{bk-prefix}-tab-header--has-num-bracket,
          .@{bk-prefix}-tab-header--has-num-square,
          .@{bk-prefix}-tab-header--has-num-elliptic {
            color: @tab-active;
          }
          .@{bk-prefix}-tab-header--has-num-square {
            background-color: @tab-card-number-active;
          }
        }
      }
    }

    &--close {
      display: none;
      font-size: 16px;
      color: @tab-gray;
    }

    &--disabled {
      cursor: not-allowed;

      &,
      &:hover {
        color: @tab-disable-color;
      }
    }
  }

  &-header-active-bar {
    position: absolute;
    width: 0;
    height: 0;
    background: @tab-active;
    transition: all ease-in 300ms;
  }

  &-content {
    flex: 1;
    padding: 10px;


    .@{bk-prefix}-tab--border-card &, .@{bk-prefix}-tab--vertical-card & {
      border: solid @tab-border;
      border-width: 0 1px 1px;
    }

    .@{bk-prefix}-tab--card-grid & {
      background: #fff;
      border-radius: 0 4px 4px 4px;
      box-shadow: 0 2px 4px 0 #1919290d;
    }
  }

  &-panel {
    height: 100%;
  }


}



