/* Before After Widget Styles */
.before-after-container {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: visible;
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.before-after-container.auto-height {
    height: auto;
}

.before-after-container[data-orientation="vertical"] {
    cursor: row-resize;
}

.before-after-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.before-after-container.auto-height .before-after-wrapper {
    height: auto;
}

.before-after-before,
.before-after-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.before-after-container.auto-height .before-after-before,
.before-after-container.auto-height .before-after-after {
    position: absolute;
    height: auto;
}

.before-after-before img,
.before-after-after img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.before-after-container.auto-height .before-after-before img,
.before-after-container.auto-height .before-after-after img {
    height: auto;
    object-fit: initial;
}

.before-after-after {
    clip-path: inset(0 50% 0 0);
    /* transition: clip-path 0.3s ease; */
    z-index: 2;
}

.before-after-container[data-orientation="vertical"] .before-after-after {
    clip-path: inset(50% 0 0 0);
    /* This will be overridden by JS, but provides initial state */
}

/* Divider Line */
.before-after-divider {
    position: absolute;
    background-color: #ffffff;
    z-index: 3;
}

.before-after-container[data-orientation="horizontal"] .before-after-divider {
    top: 0;
    left: 50%;
    width: 5px !important;
    height: 100%;
    transform: translateX(-50%);
}

.before-after-container[data-orientation="vertical"] .before-after-divider {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}

/* Handle */
.before-after-handle {
    position: absolute;
    z-index: 4;
    background-color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding-top: 3px;
    gap: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.before-after-container[data-orientation="horizontal"] .before-after-handle {
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    transform: translate(-50%, -50%);
    cursor: col-resize;
}

.before-after-container[data-orientation="vertical"] .before-after-handle {
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
    cursor: row-resize;
}

.before-after-handle:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
.before-after-container[data-orientation="horizontal"] .handle-left-arrow {
    position: relative;
}

.before-after-container[data-orientation="horizontal"] .handle-left-arrow:before {
    content: url(../img/before_after_left_arrow.svg);
}

.before-after-container[data-orientation="horizontal"] .handle-right-arrow:before {
    content: url(../img/before_after_right_arrow.svg);
}

/* Labels */
.before-after-label {
    position: absolute;
    z-index: 5;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 5px 30px;
    border-radius: 0px;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.6em;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.before-after-label.before-label {
    top: -15px;
    left: 17%;
    background-color: #000;
}

.before-after-label.after-label {
    top: -15px;
    right: 17%;
    background: linear-gradient(109deg, #FF00FE 17.73%, #48598F 101.62%);
    backdrop-filter: blur(7.199999809265137px);
}

/* Vertical orientation label positioning */
.before-after-container[data-orientation="vertical"] .before-after-label.after-label {
    top: auto;
    bottom: 20px;
    right: auto;
    left: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {

    /* Container height for vertical orientation */
    .before-after-container {
        height: 600px;
    }

    .before-after-handle {
        transform: translate(-50%, -50%) rotate(90deg) !important;
    }

    .before-after-container[data-orientation="vertical"] .handle-left-arrow:before {
        content: url(../img/before_after_left_arrow.svg);
    }

    .before-after-container[data-orientation="vertical"] .handle-right-arrow:before {
        content: url(../img/before_after_right_arrow.svg);
    }

    .before-after-label {
        font-size: 16px;
        padding: 10px 20px;
    }

    .before-after-divider {
        height: 5px !important;
    }

    .before-after-label.before-label {
        top: -20px;
        left: 0px;
        right: 0px;
        width: fit-content;
        margin: 0px auto;
    }

    .before-after-label.after-label {
        top: inherit !important;
        bottom: -20px !important;
        left: 0px !important;
        right: 0px !important;
        width: fit-content;
        margin: 0px auto;
    }

    /* Vertical orientation adjustments for mobile */
    .before-after-container[data-orientation="vertical"] .after-label {
        top: auto;
        bottom: 15px;
        right: auto;
        left: 15px;
    }
}

@media (max-width: 480px) {
    .before-after-handle {
        width: 45px !important;
        height: 45px !important;
        transform: translate(-50%, -50%) rotate(90deg) !important;
    }

    .before-after-container[data-orientation="horizontal"] .handle-left-arrow {
        border-width: 4px 5px 4px 0;
        left: 6px;
    }

    .before-after-container[data-orientation="horizontal"] .handle-right-arrow {
        border-width: 4px 0 4px 5px;
        right: 6px;
    }

    .before-after-label {
        padding: 5px 20px;
    }

    .before-label,
    .after-label {
        top: -15px;
    }

    .before-label {
        left: 10px;
    }

    .after-label {
        right: 10px;
    }

    /* Vertical orientation adjustments for small mobile */
    .before-after-container[data-orientation="vertical"] .after-label {
        top: auto;
        bottom: -15px !important;
        right: auto;
        left: 10px;
    }
}

/* Loading Animation */
.before-after-container.loading {
    opacity: 0.5;
}

.before-after-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Accessibility */
.before-after-container:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.before-after-container[aria-label] {
    position: relative;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .before-after-handle {
        border: 3px solid #000000;
        background-color: #ffffff;
    }

    .before-after-divider {
        background-color: #000000;
    }

    .before-after-label {
        background-color: #000000;
        color: #ffffff;
        border: 1px solid #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .before-after-after,
    .before-after-divider,
    .before-after-handle {
        transition: none;
    }

    .before-after-container.loading::after {
        animation: none;
    }
}

/* Print styles */
@media print {
    .before-after-container {
        position: static;
        height: auto;
        cursor: default;
    }

    .before-after-before,
    .before-after-after {
        position: static;
        width: 50%;
        height: auto;
        float: left;
    }

    .before-after-handle,
    .before-after-divider {
        display: none;
    }

    .before-after-after {
        clip-path: none;
    }
}
