After the Civil War and Reconstruction black voters became a majority in the south and of course at that time voted for Republicans. Then white Democrats created all kinds of obstacles to their voting to keep the south white and Democratic and it stayed that way for almost a century
At which point did the image and core values of these two American parties not only change but practically flip? It is especially interesting that apparently white racist southerners heavily refer to the Civil War times while strongly siding with the Republican party, when actually back then they were represented by the Democrats
The change was relatively recent. It happened in the 1960s and 1970s. The Democratic party had deepening division for years, between northern Democrats and Southern Democrats. Following the Civil War the "solid south" supported only the Democratic party for a century.
Northern Democrats primarily represented working people (labor unions, etc.) while Republicans became the party of the investor class and business owners. Northern Democrats naturally gravitated to the large numbers of minority workers in big cities as a source of support.
This led to greater support among northern Democrats for more protection of civil rights, something deeply opposed by southern Democrats. Following passage of the Civil Rights Act of 1964, which passed with a coalition of northern Democrats and most Republicans, southern Democrats felt their interests were no longer represented by the Democratic party.
Aware of this divide, in the late 1960's and early 1970's Nixon and the Republicans developed a "southern strategy" to appeal to southern whites who still supported segregation and opposed civil rights for blacks. Over time, most southern white migrated to the Republican party, so that by the late 1980's there were almost no conservative southern Democrats left in office.