.image-comparison {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 500px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 500px;
}

.comparison-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.comparison-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.before-image {
    z-index: 2; /* Place original image on top */
    clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
    transition: clip-path 0.1s ease-out;
}

.after-image {
    z-index: 1;
    width: 100%;
    height: 100%;
}

.comparison-slider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: #fff;
    transform: translateX(-50%);
    z-index: 3;
    cursor: ew-resize;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-handle::before,
.slider-handle::after {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
    font-size: 18px;
}

.slider-handle::before {
    content: '←';
    left: -20px;
}

.slider-handle::after {
    content: '→';
    right: -20px;
}

.comparison-label {
    position: absolute;
    bottom: 20px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 14px;
    border-radius: 20px;
    z-index: 3;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Show labels only when images are loaded */
.image-comparison.has-images .comparison-label {
    opacity: 1;
    visibility: visible;
}

.before-label {
    left: 20px;
}

.after-label {
    right: 20px;
}

.no-image-message {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    color: var(--text-color);
    z-index: 10;
    border-radius: 12px;
}

.no-image-message i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.no-image-message p {
    font-size: 16px;
    opacity: 0.8;
}

/* Hide no-image message when images are loaded */
.image-comparison.has-images .no-image-message {
    display: none;
}

/* Show comparison elements when images are loaded */
.image-comparison.has-images .comparison-item,
.image-comparison.has-images .comparison-slider,
.image-comparison.has-images .comparison-label {
    opacity: 1;
    visibility: visible;
}

.placeholder-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    z-index: 1;
}

.image-comparison:not(.has-images) .placeholder-image {
    display: block;
}

.image-comparison.has-images .placeholder-image {
    display: none;
}
