/* Image Comparison Slider Styles */

/* Container styling for treatment comparison */
.treatment-comparison-container {
    width: 100%;
    max-width: 100%;
    margin: 15px 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: #fff;
}

/* Main comparison slider component */
.treatment-comparison-slider {
    width: 100%;
    height: auto;
    min-height: 200px;
    display: block;
    border-radius: 12px;
    overflow: hidden;

    /* Custom CSS variables for styling */
    --divider-width: 3px;
    --divider-color: #ffffff;
    --divider-shadow: 0 0 8px rgba(0,0,0,0.3);
    --default-handle-width: 60px;
    --default-handle-color: #ffffff;
    --default-handle-opacity: 0.9;
    --default-handle-shadow: 0 2px 8px rgba(0,0,0,0.3);
    --handle-position-start: 50%;
}

/* Images within the comparison slider */
.comparison-before-image,
.comparison-after-image {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    display: block;
}

/* Hover effects */
.treatment-comparison-slider:hover {
    --default-handle-opacity: 1;
    --divider-shadow: 0 0 12px rgba(0,0,0,0.4);
}

/* Focus styles for accessibility */
.treatment-comparison-slider:focus {
    outline: 2px solid var(--wp--preset--color--primary, #007cba);
    outline-offset: 2px;
}

/* Grid integration styles */
.treatment-grid-item .treatment-comparison-container {
    margin-top: 15px;
}

.treatment-grid-item h3 + .treatment-comparison-container {
    margin-top: 10px;
}

/* Labels for before/after */
.treatment-comparison-container::before {
    content: '';
    position: relative;
    display: block;
}

/* Optional: Add before/after labels */
.treatment-comparison-container[data-labels="true"]::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 30px;
    pointer-events: none;
    z-index: 10;
}

.treatment-comparison-container[data-labels="true"]::after {
    background: linear-gradient(
        to right,
        rgba(0,0,0,0.7) 0%,
        rgba(0,0,0,0.7) 20px,
        transparent 20px,
        transparent calc(100% - 20px),
        rgba(0,0,0,0.7) calc(100% - 20px),
        rgba(0,0,0,0.7) 100%
    );
}

/* Responsive design */
@media (max-width: 768px) {
    .treatment-comparison-slider {
        min-height: 250px;
        --default-handle-width: 50px;
    }

    .comparison-before-image,
    .comparison-after-image {
        max-height: 300px;
    }

    .treatment-comparison-container {
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .treatment-comparison-slider {
        min-height: 200px;
        --default-handle-width: 40px;
        --divider-width: 2px;
    }

    .comparison-before-image,
    .comparison-after-image {
        max-height: 250px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .treatment-comparison-slider {
        --divider-color: #000000;
        --default-handle-color: #000000;
        border: 2px solid #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .treatment-comparison-slider {
        --default-transition-time: 0ms;
        --keyboard-transition-time: 0ms;
    }
}

/* Loading state */
.treatment-comparison-container.loading {
    background: #f5f5f5;
    position: relative;
}

.treatment-comparison-container.loading::before {
    content: 'Loading comparison...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-style: italic;
    z-index: 10;
}

/* Error state */
.treatment-comparison-container.error {
    background: #ffe6e6;
    border-color: #ff9999;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.treatment-comparison-container.error::before {
    content: 'Unable to load comparison images';
    color: #cc0000;
    font-style: italic;
}

/* Integration with existing grid styles */
.treatment-grid-item .treatment-comparison-container {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
}

.treatment-grid-item .treatment-comparison-slider {
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Custom handle styles for treatment theme */
.treatment-comparison-slider::part(handle) {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--wp--preset--color--primary, #007cba);
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

/* Thicker arrow icons - 50% increase */
.treatment-comparison-slider .default-handle path {
    stroke-width: 1.5px !important;
}

/* Vertical orientation styles */
.treatment-comparison-slider[direction="vertical"] {
    height: 400px;
}

.treatment-comparison-slider[direction="vertical"] .comparison-before-image,
.treatment-comparison-slider[direction="vertical"] .comparison-after-image {
    height: 100%;
    max-height: none;
    object-fit: cover;
}

@media (max-width: 768px) {
    .treatment-comparison-slider[direction="vertical"] {
        height: 300px;
    }
}

/* Print styles */
@media print {
    .treatment-comparison-container {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }

    .treatment-comparison-slider {
        display: block;
        position: relative;
    }

    .comparison-before-image {
        display: block;
        width: 48%;
        float: left;
        margin-right: 2%;
    }

    .comparison-after-image {
        display: block;
        width: 48%;
        float: right;
        margin-left: 2%;
    }

    .comparison-before-image::after {
        content: "Before";
        display: block;
        text-align: center;
        font-weight: bold;
        padding: 5px;
        background: #f0f0f0;
    }

    .comparison-after-image::after {
        content: "After";
        display: block;
        text-align: center;
        font-weight: bold;
        padding: 5px;
        background: #f0f0f0;
    }
}