
.before-after-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    /* Force GPU acceleration */
    transform: translateZ(0);
    will-change: auto;
}

.before-after-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.before-image, .after-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    pointer-events: none;
}

.after-image {
    z-index: 1;
}

.before-image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%; /* Initial width - will be updated by JS */
    height: 100%;
    z-index: 2;
    overflow: hidden; /* This clips the image instead of clip-path */
    /* Remove the clip-path and transition */
}

.before-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Force hardware acceleration */
    transform: translateZ(0);
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 0; /* Will be positioned by transform */
    transform: translateX(-50%) translateY(-50%); /* Will be updated by JS */
    border-radius: 50%;
    cursor: ew-resize;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    /* Only transition when not dragging */
    transition: none;
    /* Force GPU acceleration */
    will-change: transform;
}

.slider-handle:hover {
    /* Use transform instead of changing transform property */
    filter: brightness(1.1);
}

.handle-line {
    position: absolute;
    width: 2px;
    height: 100vh;
    background-color: currentColor;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.before-label, .after-label {
    position: absolute;
    top: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    z-index: 5;
    /* Optimize text rendering */
    text-rendering: optimizeSpeed;
}

.before-label {
    left: 20px;
}

.after-label {
    right: 20px;
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
    .before-after-container {
        margin: 10px 0;
        /* Disable some effects on mobile for better performance */
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .before-label, .after-label {
        top: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .before-label {
        left: 10px;
    }
    
    .after-label {
        right: 10px;
    }
    
    .slider-handle {
        /* Larger touch target on mobile */
        min-width: 44px;
        min-height: 44px;
    }
}