// panel
.yc-color-picker-panel {
  overflow: hidden;
  width: 260px;
  background-color: var(--color-bg-1);
  border-radius: var(--border-radius-small);
  box-shadow: 0 8px 20px 0 rgba(0, 0, 0, 0.1);
  .yc-color-picker-palette {
    overflow: hidden;
    position: relative;
    cursor: pointer;
    width: 100%;
    height: 178px;
    background-image: linear-gradient(0deg, #000, transparent),
      linear-gradient(90deg, #fff, rgba(255, 255, 255, 0));
    border: 1px solid var(--color-border-2);
    border-bottom: 0;
    .yc-color-picker-handler {
      position: absolute;
      width: 16px;
      height: 16px;
      border: 2px solid #fff;
      border-radius: var(--border-radius-circle);
      background-color: transparent;
      transform: translate(-50%, -50%);
    }
  }
  .yc-color-picker-panel-control {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    .yc-color-picker-control-wrapper {
      display: flex;
      justify-content: space-between;
      align-items: center;
      &:not(.yc-color-picker-preview) > div {
        display: flex;
        flex-direction: column;
        gap: 12px;
      }
      .yc-color-picker-control-bar {
        cursor: pointer;
        position: relative;
        width: 182px;
        height: 14px;
        border-radius: 10px;
        border: 1px solid var(--color-border-2);
        background-image: linear-gradient(
          90deg,
          #f00 0,
          #ff0 17%,
          #0f0 33%,
          #0ff 50%,
          #00f 67%,
          #f0f 83%,
          #f00
        );

        .yc-color-picker-control-bar-handler {
          user-select: none;
          position: absolute;
          top: 50%;
          transform: translate(-50%, -50%);
          width: 16px;
          height: 16px;
          border-radius: var(--border-radius-circle);
          border: 1px solid var(--color-border-2);

          &::before {
            display: block;
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 8px;
            height: 8px;
            background: currentColor;
            border-radius: var(--border-radius-circle);
          }
          &::after {
            display: block;
            content: '';
            width: 100%;
            height: 100%;
            background: var(--color-bg-white);
            border-radius: var(--border-radius-circle);
          }
        }
      }
      .yc-color-picker-control-bar-bg {
        width: fit-content;
        height: fit-content;
        background-image: conic-gradient(
          rgba(0, 0, 0, 0.06) 0 25%,
          transparent 0 50%,
          rgba(0, 0, 0, 0.06) 0 75%,
          transparent 0
        );
        background-size: 8px 8px;
        border-radius: 10px;
      }
      .yc-color-picker-preview {
        width: 40px;
        height: 40px;
        border: 1px solid var(--color-border-2);
        border-radius: var(--border-radius-medium);
      }
    }
    .yc-color-picker-input-wrapper {
      display: flex;
      align-items: center;
      gap: 20px;

      .yc-input-outer {
        .yc-input-wrapper {
          padding: 0 6px;
          .yc-input-suffix {
            padding-left: 0;
          }
        }
      }
      .yc-color-picker-format {
        .yc-select {
          width: 58px;
        }
      }
      .yc-color-picker-color {
        flex: 1;
        overflow: hidden;
        .rgb-input,
        .hex-input {
          flex: 1;
          &.rgb-input {
            .yc-input {
              text-align: center;
            }
          }
        }
        .alpha-input {
          width: 52px;
        }
      }
    }
  }
  .yc-color-picker-panel-colors {
    padding: 12px;
    border-top: 1px solid var(--color-border-2);
    display: flex;
    flex-direction: column;
    gap: 12px;
    .yc-color-picker-colors-section {
      display: flex;
      flex-direction: column;
      gap: 6px;
      .yc-color-picker-colors-text {
        color: var(--color-text-1);
        font-weight: 400;
        font-size: 12px;
      }
      .yc-color-picker-colors-empty {
        margin: 6px 0 0 0;
        color: var(--color-text-3);
        font-size: 12px;
      }
      .yc-color-picker-colors-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 4px;
        .yc-color-picker-color-block {
          cursor: pointer;
          width: 16px;
          height: 16px;
          overflow: hidden;
          background-image: conic-gradient(
            rgba(0, 0, 0, 0.06) 0 25%,
            transparent 0 50%,
            rgba(0, 0, 0, 0.06) 0 75%,
            transparent 0
          );
          background-size: 8px 8px;
          border-radius: var(--border-radius-small);
          transition: transform ease-out 60ms;
          &:hover {
            transform: scale(1.1);
          }
          .yc-color-picker-block {
            height: 100%;
            width: 100%;
          }
        }
      }
    }
  }
}

// panel disabled state
.yc-color-picker-panel-disabled {
  cursor: not-allowed;
  .yc-color-picker-palette {
    cursor: not-allowed;
  }
  .yc-color-picker-panel-control {
    .yc-color-picker-control-wrapper {
      .yc-color-picker-control-bar {
        cursor: not-allowed;
      }
    }
  }
}

// picker
.yc-color-picker {
  cursor: pointer;
  background-color: var(--color-fill-2);
  border-radius: var(--border-radius-small);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  &:not(.yc-color-picker-disabled):hover {
    background-color: var(--color-fill-3);
  }
  .yc-color-picker-value {
    color: var(--color-text-1);
    font-weight: 400;
  }

  // disabled state
  &.yc-color-picker-disabled {
    cursor: not-allowed;
    background-color: var(--color-fill-2);
    .yc-color-picker-value {
      color: var(--color-text-4);
    }
  }
}
// size
@size: {
  @mini: {
    size: 24px;
    padding: 4px;
  };
  @small: {
    size: 28px;
    padding: 3px 4px;
  };
  @medium: {
    size: 32px;
    padding: 4px;
  };
  @large: {
    size: 36px;
    padding: 5px;
  };
};
each(@size, .(@value, @name) {
  @key: replace(~'@{name}', '@', '');
  @font-size:if(@key=mini,12px,14px);
  .yc-color-picker-size-@{key} {
    height: @value[size];
    padding: @value[padding];
    font-size: @font-size;
    .yc-color-picker-preview {
      height: 100%;
      width: if(
        @key = large,
        calc(@value[size] - 10px),
        calc(@value[size] - 8px)
      );
    }
  }
});
