/* Before After Slider Frontend Styles */

.ba-slider-container {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ba-slider {
    position: relative;
    overflow: hidden;
    cursor: grab;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    background: #f0f0f0;
    width: 100%;
    height: 100%;
    min-height: 300px;
}

.ba-slider.ba-dragging {
    cursor: grabbing;
}

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

.ba-before img,
.ba-after img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.ba-after {
    clip-path: inset(0 0 0 50%);
    transition: clip-path 0.1s ease-out;
}

.ba-slider.ba-dragging .ba-after {
    transition: none;
}

/* Handle Styles */
.ba-handle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    transform: translateX(-50%);
    cursor: ew-resize;
    z-index: 10;
    transition: left 0.1s ease-out;
}

.ba-slider.ba-dragging .ba-handle {
    transition: none;
}

.ba-handle::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid rgba(255, 255, 255, 0.9);
}

.ba-handle::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 20px solid rgba(255, 255, 255, 0.9);
}

.ba-handle-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.ba-handle-button::before {
    content: '↔';
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.ba-handle:hover .ba-handle-button {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%) scale(1.1);
}

.ba-handle:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Labels */
.ba-label {
    position: absolute;
    bottom: 20px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: opacity 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ba-label-before {
    left: 20px;
}

.ba-label-after {
    right: 20px;
}

/* Description */
.ba-description {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

.ba-description p:last-child {
    margin-bottom: 0;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .ba-handle-button {
        width: 35px;
        height: 35px;
    }
    
    .ba-handle-button::before {
        font-size: 14px;
    }
    
    .ba-label {
        font-size: 12px;
        padding: 6px 12px;
        bottom: 15px;
    }
    
    .ba-label-before {
        left: 15px;
    }
    
    .ba-label-after {
        right: 15px;
    }
    
    .ba-slider {
        min-height: 250px;
    }
}

@media screen and (max-width: 480px) {
    .ba-handle-button {
        width: 30px;
        height: 30px;
    }
    
    .ba-handle-button::before {
        font-size: 12px;
    }
    
    .ba-label {
        font-size: 11px;
        padding: 4px 8px;
        bottom: 10px;
    }
    
    .ba-label-before {
        left: 10px;
    }
    
    .ba-label-after {
        right: 10px;
    }
    
    .ba-slider {
        min-height: 200px;
        border-radius: 6px;
    }
    
    .ba-description {
        font-size: 13px;
        padding: 12px;
    }
}

/* Loading State */
.ba-slider.ba-loading {
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ba-slider.ba-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #ddd;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: ba-spin 1s linear infinite;
}

@keyframes ba-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.ba-slider.ba-error {
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 14px;
}

.ba-slider.ba-error::before {
    content: '⚠ ';
    margin-right: 5px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .ba-handle {
        background: #000;
    }
    
    .ba-handle::before,
    .ba-handle::after {
        border-bottom-color: #000;
        border-top-color: #000;
    }
    
    .ba-handle-button {
        background: #fff;
        border: 2px solid #000;
    }
    
    .ba-label {
        background: #000;
        color: #fff;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .ba-after,
    .ba-handle,
    .ba-handle-button,
    .ba-label {
        transition: none;
    }
    
    .ba-handle:hover .ba-handle-button {
        transform: translate(-50%, -50%);
    }
}

/* Print Styles */
@media print {
    .ba-slider {
        break-inside: avoid;
    }
    
    .ba-handle {
        display: none;
    }
    
    .ba-after {
        clip-path: none;
        opacity: 0.5;
    }
    
    .ba-label {
        background: transparent;
        color: #000;
        border: 1px solid #000;
    }
}

/* RTL Support */
.rtl .ba-label-before {
    left: auto;
    right: 20px;
}

.rtl .ba-label-after {
    right: auto;
    left: 20px;
}

/* Custom Properties for Theme Integration */
.ba-slider-container {
    --ba-handle-color: rgba(255, 255, 255, 0.9);
    --ba-button-bg: rgba(255, 255, 255, 0.95);
    --ba-button-hover-bg: white;
    --ba-label-bg: rgba(0, 0, 0, 0.7);
    --ba-label-color: white;
    --ba-description-bg: #f8f9fa;
    --ba-description-color: #555;
    --ba-border-radius: 8px;
    --ba-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Theme-specific overrides can use these custom properties */
.ba-slider {
    border-radius: var(--ba-border-radius);
    box-shadow: var(--ba-shadow);
}

.ba-handle {
    background: var(--ba-handle-color);
}

.ba-handle-button {
    background: var(--ba-button-bg);
}

.ba-handle:hover .ba-handle-button {
    background: var(--ba-button-hover-bg);
}

.ba-label {
    background: var(--ba-label-bg);
    color: var(--ba-label-color);
}

.ba-description {
    background: var(--ba-description-bg);
    color: var(--ba-description-color);
}