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

.@{bk-prefix}-color-picker {
  position: relative;
  display: inline-flex;
  height: 32px;
  color: #63656e;
  cursor: pointer;
  border: 1px solid #dcdee5;
  border-radius: 2px;
  outline: none;
  transition: border .2s, box-shadow .2s;
  align-content: center;

  &.@{bk-prefix}-color-picker-show-value {
    width: 150px;
  }

  &.@{bk-prefix}-color-picker-large {
    height: 36px;

    &.@{bk-prefix}-color-picker-show-value {
      width: 170px;

      .@{bk-prefix}-color-picker-text {
        width: calc(100% - 62px);
        font-size: 16px;
      }
    }

    .@{bk-prefix}-color-picker-color .@{bk-prefix}-color-picker-color-square {
      width: 22px;
      height: 22px;
      font-size: 22px;
    }
  }

  &.@{bk-prefix}-color-picker-small {
    height: 28px;

    &.@{bk-prefix}-color-picker-show-value {
      width: 132px;

      .@{bk-prefix}-color-picker-text {
        width: calc(100% - 56px);
        font-size: 12px;
      }
    }

    .@{bk-prefix}-color-picker-color .@{bk-prefix}-color-picker-color-square {
      width: 16px;
      height: 16px;
      font-size: 16px;
    }
  }

  &:hover,
  &:focus {
    border-color: #3a84ff;
    transition: border .2s;
  }

  &.@{bk-prefix}-color-picker-show-dropdown {
    border-color: #3a84ff;
    box-shadow: 0 0 0 2px rgba(45, 140, 240, .2);
    transition: border .2s, box-shadow .2s;

    .@{bk-prefix}-icon-angle-down {
      transform: rotate(-180deg);
      transition: transform .3s;
    }
  }

  &.@{bk-prefix}-color-picker-disabled {
    cursor: not-allowed;
    background-color: #e1ecff;
    border-color: #699df4;

    .@{bk-prefix}-color-picker-text {
      color: #3a84ff;
    }

    .@{bk-prefix}-color-picker-icon .@{bk-prefix}-icon-angle-down {
      color: #3a84ff;
    }
  }

  .@{bk-prefix}-color-picker-color {
    display: flex;
    margin-left: 6px;
    align-items: center;

    .@{bk-prefix}-color-picker-color-square {
      width: 18px;
      height: 18px;
      font-size: 18px;
      color: #3a84ff;
      box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
    }
  }

  .@{bk-prefix}-color-picker-text {
    display: flex;
    width: calc(100% - 58px);
    margin-left: 6px;
    font-size: 14px;
    line-height: 20px;
    color: #63656e;
    align-items: center;

    span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .@{bk-prefix}-color-picker-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 20px;
    margin-right: 5px;
    transform: rotate(180deg);


    .@{bk-prefix}-icon-angle-down {
      position: absolute;
      right: 4px;
      display: flex;
      align-items: center;
      font-size: 20px;
      color: #979ba5;
      transition: transform .3s;
    }
  }
}

/*下拉面板*/
.@{bk-prefix}-color-picker-dropdown {
  width: 272px;
}

.@{bk-prefix}-color-picker-saturation {
  position: relative;
  height: 180px;
  margin: 0 6px 6px;

  .@{bk-prefix}-color-picker-saturation-white {
    background: linear-gradient(90deg, #fff, hsla(0, 0%, 100%, 0));
  }

  .@{bk-prefix}-color-picker-saturation-black {
    background: linear-gradient(0deg, #000, transparent);
  }

  .@{bk-prefix}-color-picker-saturation-white,
  .@{bk-prefix}-color-picker-saturation-black {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
  }
}

.@{bk-prefix}-color-picker-hue {
  position: relative;
  height: 10px;
  margin: 0 6px 6px;
  cursor: pointer;
  background: linear-gradient(90deg, red 0, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red);

  .@{bk-prefix}-color-picker-hue-pointer {
    position: absolute;
    top: 0;

    .@{bk-prefix}-color-picker-hue-rectangle {
      width: 4px;
      height: 8px;
      margin-top: 1px;
      cursor: pointer;
      background: #fff;
      border-radius: 1px;
      transform: translateX(-2px);
      box-shadow: 0 0 2px rgba(0, 0, 0, .6);
    }
  }
}

.@{bk-prefix}-color-picker-input {
  display: flex;
  margin: 0 6px 1px;
  font-size: 12px;
  color: #63656e;
  justify-content: space-between;

  .@{bk-prefix}-color-picker-input-hex .@{bk-prefix}-color-picker-input-part .@{bk-prefix}-color-picker-input-value {
    width: 70px;
  }

  .@{bk-prefix}-color-picker-input-rgba {
    display: flex;
    width: 160px;
    justify-content: space-between;
  }

  .@{bk-prefix}-color-picker-input-part {
    display: flex;
    flex-flow: column;

    .@{bk-prefix}-color-picker-input-value {
      width: 32px;
      height: 22px;
      padding: 0 4px;
      line-height: 16px;
      border: 1px solid #c4c6cc;
      border-radius: 2px;
      outline: none;
      transition: border .2s;

      &:focus {
        border-color: #3a84ff;;
        transition: border .2s;
      }

      &.error {
        border-color: #3a84ff;
      }

      &::-we@{bk-prefix}it-outer-spin-button,
      &::-we@{bk-prefix}it-inner-spin-button {
        margin: 0;
        appearance: none;
      }
    }

    .@{bk-prefix}-color-picker-input-text {
      height: 18px;
      line-height: 18px;
      text-align: center;
    }
  }
}

.@{bk-prefix}-color-picker-recommend-container {
  padding: 6px;
  border-top: 1px solid #f0f1f5;

  .@{bk-prefix}-color-picker-recommend {
    display: flex;
    flex-wrap: wrap;

    .@{bk-prefix}-color-picker-recommend-color {
      width: 20px;
      height: 20px;
      margin: 3px;
      cursor: pointer;
      border-radius: 3px;
      box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);

      &.@{bk-prefix}-color-picker-recommend-selected-color {
        box-shadow: 0 0 3px 2px #3a84ff;;
      }
    }
  }
}

.@{bk-prefix}-color-picker-saturation,
.@{bk-prefix}-color-picker-hue,
.@{bk-prefix}-color-picker-recommend {
  outline: none;
  transition: box-shadow .2s;

  &:focus {
    box-shadow: 0 0 0 2px rgba(45, 140, 240, .5);
    transition: box-shadow .2s;
  }
}

/*饱和度和预设值共用样式*/
.@{bk-prefix}-color-picker-pointer {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  cursor: pointer;

  .@{bk-prefix}-color-picker-circle {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 4px;
    cursor: pointer;
    border-radius: 50%;
    transform: translate(-2px, -2px);
    box-shadow: 0 0 0 1.5px #fff, inset 0 0 1px 1px rgba(0, 0, 0, .3), 0 0 1px 2px rgba(0, 0, 0, .4);
  }
}

.@{bk-prefix}-color-picker-empty {
  position: relative;

  &::after {
    position: absolute;
    top: 1px;
    left: calc(50% - 1px);
    width: 2px;
    height: calc(100% - 2px);
    background: #ea3536;
    border-radius: 1px;
    content: '';
    transform: rotate(45deg);
  }
}

.@{bk-prefix}-color-dropdown-container {
  padding: 0px;
  cursor: default;
  transform-origin: center top;
  will-change: top, left;
}
