/* 
 * Poprawiony CSS dla widgetu porównywania zdjęć Przed/Po
 * z perfekcyjnym nakładaniem zdjęć na siebie
 */

.elementor-before-after-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    touch-action: none;
    height: 400px; /* Domyślna wysokość, zmieniana przez kontrolki Elementora */
}

/* Wspólne style dla obu obrazów - absolutne pozycjonowanie z wyrównaniem */
.elementor-before-after-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    display: block;
    object-fit: cover; /* domyślne wypełnienie */
    object-position: center; /* domyślne wycentrowanie */
    transform-origin: center;
    max-width: none;
}

/* Dodatkowe opcje pozycjonowania obrazów */
.image-position-left img {
    object-position: left center;
}

.image-position-right img {
    object-position: right center;
}

.image-position-top img {
    object-position: center top;
}

.image-position-bottom img {
    object-position: center bottom;
}

/* Kontenery zdjęć */
.before-image-container,
.after-image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Po zawsze na spodzie */
.after-image-container {
    z-index: 1;
}

/* Przed zawsze na wierzchu */
.before-image-container {
    z-index: 2;
    clip-path: inset(0 50% 0 0); /* Domyślnie pokazuj lewą połowę */
}

/* Zmiana dla orientacji pionowej */
.orientation-vertical .before-image-container {
    clip-path: inset(0 0 50% 0); /* Domyślnie pokazuj górną połowę */
}

/* Linia podziału */
.before-after-divider {
    position: absolute;
    top: 0;
    left: 50%; /* Domyślna pozycja */
    width: 2px;
    height: 100%;
    background-color: #fff;
    z-index: 15;
    transform: translateX(-1px);
    cursor: ew-resize;
}

/* W orientacji pionowej */
.orientation-vertical .before-after-divider {
    left: 0;
    top: 50%;
    width: 100%;
    height: 2px;
    transform: translateY(-1px);
    cursor: ns-resize;
}

/* Uchwyt suwaka */
.before-after-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #fff;
    transform: translate(-50%, -50%);
    z-index: 20;
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: ew-resize;
    transition: box-shadow 0.3s ease;
}

.before-after-handle:hover {
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* Ikona strzałek w uchwycie */
.handle-arrows {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.handle-arrows:before {
    content: "";
    border-style: solid;
    border-width: 7px 0 7px 7px;
    border-color: transparent transparent transparent #333;
    position: absolute;
    left: 8px;
}

.handle-arrows:after {
    content: "";
    border-style: solid;
    border-width: 7px 7px 7px 0;
    border-color: transparent #333 transparent transparent;
    position: absolute;
    right: 8px;
}

/* W orientacji pionowej */
.orientation-vertical .before-after-handle {
    cursor: ns-resize;
}

.orientation-vertical .handle-arrows:before {
    border-width: 0 7px 7px 7px;
    border-color: transparent transparent #333 transparent;
    left: auto;
    top: 8px;
}

.orientation-vertical .handle-arrows:after {
    border-width: 7px 7px 0 7px;
    border-color: #333 transparent transparent transparent;
    right: auto;
    bottom: 8px;
}

/* Etykiety */
.before-label,
.after-label {
    position: absolute;
    background-color: rgba(0,0,0,0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    pointer-events: none;
}

.before-label {
    top: 10px;
    left: 10px;
}

.after-label {
    top: 10px;
    right: 10px;
}

/* Responsywność */
@media only screen and (max-width: 767px) {
    .before-after-handle {
        width: 34px;
        height: 34px;
    }
    
    .handle-arrows:before {
        border-width: 6px 0 6px 6px;
        left: 7px;
    }
    
    .handle-arrows:after {
        border-width: 6px 6px 6px 0;
        right: 7px;
    }
    
    .before-label,
    .after-label {
        font-size: 12px;
        padding: 4px 8px;
    }
}

/* Specjalne style dla urządzeń dotykowych */
@media (hover: none) {
    .before-after-handle {
        width: 44px;
        height: 44px;
    }
    
    .handle-arrows:before {
        border-width: 8px 0 8px 8px;
        left: 9px;
    }
    
    .handle-arrows:after {
        border-width: 8px 8px 8px 0;
        right: 9px;
    }
}

/* Animacja przy przejściu */
.elementor-before-after-container {
    transition: opacity 0.3s ease;
}

.elementor-before-after-container.loading {
    opacity: 0;
}