@import './../theme/vars.scss';
@import './colorPanel.scss';
@import './../mixins/connect.scss';

$colorPickerPrefixCls: #{$vender-prefix}-color-picker;
$customColorPickerPrefixCls: #{$vender-prefix}-custom-color-picker;
$color-wrapper-border: #f7f7f7;
$color-value-border: #5f5f5f;

$colorBgDefault: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQMAAACQp+OdAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURefn5////3/E1qkAAAAXSURBVCjPY2AAgv9AwDDKwMoYDQm8DADzAv8BBwl+JwAAAABJRU5ErkJggg==');

.#{$colorPickerPrefixCls} {
  display: inline-block;

  &-swatch {
    position: relative;
    display: inline-block;
    padding: 1px 18px 5px 5px;
    cursor: pointer;
    background: white;
    border: solid 1px $color-wrapper-border;
    border-radius: 1px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    user-select: none;

    &::after {
      position: absolute;
      top: 2px;
      right: 5px;
      content: '▼';
    }
  }

  &-color {
    display: inline-block;
    width: 36px;
    height: 14px;
    vertical-align: middle;
    border: solid 1px $color-value-border;
    border-radius: 2px;
  }

  &-popover {
    position: absolute;
    z-index: 2;
  }

  &-mask {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  &.#{$colorPickerPrefixCls}-disabled {
    background: $colorpicker-disable-color;

    .#{$colorPickerPrefixCls}-swatch {
      cursor: not-allowed;
      background: $colorpicker-disable-color;
    }
  }
}

// -- drop color
.drop-color-popover {
  &::after {
    display: none;
  }

  &-content {
    max-width: 250px;
    min-height: 36px;
    padding: 0;
    background: white;
  }

  &.amos-popover-down {
    padding-top: 3px;
  }

  &.amos-popover-up {
    padding-bottom: 3px;
    margin-top: -3px;
  }
}

// custom color picker
@include makeColorPanel($customColorPickerPrefixCls);

// custom color panel
@include makeColorPanel(custom-color);

// input color
$inputColorPrefixCls: #{$vender-prefix}-input-color;

.#{$inputColorPrefixCls} {
  display: flex;
  width: 100%;

  &-inner {
    display: inline-table;
    width: 200px;
    height: 24px;
    font-size: 0;
    line-height: 1;
    vertical-align: middle;
    background: white;
    border: 1px solid #dedede;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 0;
    transition: all 0.1s linear;

    &:hover {
      border-color: var(--primary-color);
      box-shadow: $focus-shadow;
    }
  }

  &-disabled {
    .#{$inputColorPrefixCls}-inner {
      &:hover {
        background: #f3f3f3;
        border-color: #dedede;
        box-shadow: none;
      }
    }
  }

  &-addon,
  &-addon-after {
    display: table-cell;
    width: 1px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
    background-color: transparent;
  }

  &-addon-after {
    cursor: pointer;

    .aficon-opacity {
      margin-right: 4px;
    }
  }

  &-trigger {
    position: relative;

    &-background {
      position: relative;
      width: 16px;
      height: 16px;
      margin: auto 0 auto 4px;
      cursor: pointer;
      background: $colorBgDefault;
      background-size: 7px 7px;
      border: 1px solid gainsboro;
      box-sizing: border-box;
    }
  }

  &-colorvalue {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  .amos-input.inputcolor-input {
    width: 100%;
    height: 2.5em;
    padding: 0 4px;
    margin: 0;
    font-size: 12px;
    font-weight: normal;
    line-height: 2.5em;
    color: #333;
    vertical-align: middle;
    background-color: transparent;
    border: none;
    outline: none;

    &:focus {
      border: none;
      outline: none;
      box-shadow: none;
    }
  }

  &-popover {
    &::after {
      display: none;
    }

    &-content {
      width: 200px;
      padding: 10px 10px 0;
      background: white;
      border-radius: 4px;
      box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.15);

      // SketchPicker input 设置 box-sizing
      .sketch-picker .flexbox-fix input {
        box-sizing: content-box;
      }
    }

    &.amos-popover-down {
      padding-top: 10px;
    }

    &.amos-popover-up {
      padding-bottom: 9px;
      margin-top: -9px;
    }
  }
}

// -- Gradient Picker
$gradientPicker: #{$vender-prefix}-gradient-picker;
// custom color panel
@include makeColorPanel($gradientPicker);

// pop
.#{$gradientPicker} {
  &-popover-content {
    padding: 6px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 1px 5px #ccc;
  }

  &-panel-inner {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  &-angle-holder {
    padding-top: 6px;
    margin: 0 8px;
    margin-top: 6px;
    border-top: 1px solid #f1f1f1;
  }
}

// color list picker
.color-list-picker {
  &-item {
    display: inline-block;
    width: 16px;
    height: 16px;
    cursor: pointer;
    box-sizing: border-box;

    &:hover {
      border: 1px solid white;
    }
  }
}

// gradient picker

.gradient-picker {
  display: flex;
  flex-direction: column;
  align-items: center;

  &-flat {
    padding: 10px 0 0;
    margin: 0 auto;
    transform: none;
    box-shadow: none;
  }
}

// color stop
.rgp-color-stop {
  position: absolute;
  width: 11px;
  height: 17px;
  cursor: pointer;
  background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAARCAQAAABzuJQIAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAB7SURBVCjP3c7BDQMhDETRP4gyUlb6SEphe9w+JgdArIMPm2uGizV6MpbpERgBzGb0tuZcLvTbDSoHrMUMQmFrY/IaaOeKB7yE+1yTz43irZNXbXcCFosuXqFt9g0cyZICT7LkrU+b62vGeVv4IX+Phc+tfABZK3xj5cgHC29ECUeufxkAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDUtMzFUMTg6NDE6MzIrMDI6MDD31tLGAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA1LTMxVDE4OjQxOjMyKzAyOjAwhotqegAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAASUVORK5CYII=') right center;

  &-inner {
    position: absolute;
    top: 8px;
    left: 2px;
    width: 7px;
    height: 7px;
  }

  &-active {
    background-position: left center;
  }
}

.gp-palette {
  border: 1px solid #f1f1f1;
}

// mix color
.amos-mixcolor-panel {
  display: flex;
  width: 220px;
  flex-direction: column;
  border: 1px solid #e1e1e1;
  border-radius: 4px;
  box-shadow: 0 1px 5px #ccc;

  &-linear {
  }

  &-type {
    display: flex;
    height: 36px;
    align-items: center;
    border-bottom: 1px solid #e1e1e1;

    &-pure,
    &-linear {
      position: relative;
      width: 30px;
      height: 36px;
      cursor: pointer;

      &::before {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 16px;
        height: 16px;
        background: #666;
        border: 1px solid #666;
        border-radius: 50%;
        content: '';
        transform: translate(-50%, -50%);
      }
    }

    &-pure.color-pure-actived {
      &::before {
        background: #345fa6;
      }
    }

    &-linear {
      &::before {
        background-image: linear-gradient(#aaa, black);
      }

      &.color-linear-actived {
        &::before {
          background-image: linear-gradient(180deg, rgba(36, 145, 247, 0) 18%, #345fa6 100%);
          border: 1px solid #345fa6;
        }
      }
    }
  }

  .custom-color-panel-inner {
    border: 0;
    border-top-right-radius: 0;
    border-top-left-radius: 0;
    box-shadow: 0;
  }
}

// input mixcolor
$mixColorPicker: #{$vender-prefix}-mixcolor;
$mixColorInput: mixcolor-input;

@include with-input($mixColorPicker, $mixColorInput);

.#{$mixColorPicker} {
  .amos-input[disabled] {
    background: #f3f3f3;
  }

  &-popover-content {
    width: 220px;
    padding: 0;
    box-shadow: 0;
  }

  &-trigger {
    &-inner {
      margin: 0 4px;
      background: $colorBgDefault;
      background-size: 7px 7px;
      border: 1px solid gainsboro;
    }

    &-value {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
    }
  }
}

// drop chart color
$dropChartColor: #{$vender-prefix}-chartcolor;

@include makeColorTrigger($dropChartColor);

.#{$dropChartColor} {
  &-popover {
    &-content {
      @include pretty-scrollbar(6px, 6px, $scrollOutColor, $scrollInnerColor, 5px);

      width: 320px;
      max-height: 300px;
      min-height: 36px;
      overflow-y: auto;
      text-align: left;
      background: white;
      border-radius: 2px;
      box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.25);

      .field-group {
        padding: 0.5em 1em 1em 1.5em;

        &-content {
          border: 0;
        }
      }
    }
  }
}

// section color
$dropSectionColor: #{$vender-prefix}-sectioncolor;

@include makeColorTrigger($dropSectionColor);

.#{$dropSectionColor} {
  &-popover {
    &-content {
      @include pretty-scrollbar(6px, 6px, $scrollOutColor, $scrollInnerColor, 5px);

      width: 290px;
      max-height: 200px;
      min-height: 36px;
      padding: 12px;
      overflow-y: auto;
      text-align: left;
      background: white;
      border-radius: 2px;
      box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.25);

      .field-group {
        padding: 0.5em 1em 1em 1.5em;

        &-content {
          border: 0;
        }
      }
    }
  }
}
