/* Comparison Modal Styles */
.comparison-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.comparison-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.comparison-card {
    position: relative;
    width: 100%;
    max-width: 1100px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
    animation: modal-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.comparison-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comparison-title-group h3 {
    font-size: 1.5rem;
    font-weight: 700;
}

.comparison-subtitle {
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

.close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--error);
    color: white;
    transform: rotate(90deg);
}

.comparison-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
}

.comparison-viewer {
    position: relative;
    flex: 1;
    width: 100%;
    background: #000;
    /* Dark background for transparent images */
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background-image:
        linear-gradient(45deg, #222 25%, transparent 25%),
        linear-gradient(-45deg, #222 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #222 75%),
        linear-gradient(-45deg, transparent 75%, #222 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.comparison-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compare-img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    user-select: none;
    pointer-events: none;
}

#compareOriginal {
    position: relative;
    z-index: 1;
}

#compareOptimized {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    z-index: 2;
    clip-path: inset(0 50% 0 0);
}

.comparison-slider-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    z-index: 10;
    cursor: ew-resize;
}

.comparison-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 5;
    pointer-events: none;
}

.handle-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    border: 4px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.handle-circles-inner {
    display: flex;
    gap: 4px;
}

.handle-circles-inner div {
    width: 2px;
    height: 12px;
    background: var(--primary);
    border-radius: 2px;
}

.comparison-labels {
    position: absolute;
    bottom: 2rem;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 2rem;
    pointer-events: none;
    z-index: 6;
}

.comp-badge {
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.comparison-footer {
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.stat-pill:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -1rem;
    top: 15%;
    bottom: 15%;
    width: 1px;
    background: var(--glass-border);
    opacity: 0.5;
}

.stat-pill .label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-pill .value {
    font-size: 1.1rem;
    font-weight: 700;
}

@keyframes modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Comparison Button in Result Cards */
.btn-pill {
    padding: 0.5rem 1rem;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

.btn-pill:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}

.btn-pill svg {
    width: 16px;
    height: 16px;
}

.btn-compare {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary);
    border-color: rgba(16, 185, 129, 0.2);
}

@media (max-width: 768px) {
    .comparison-modal {
        padding: 0;
    }

    .comparison-card {
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .comparison-header {
        padding: 1rem;
    }

    .comparison-title-group h3 {
        font-size: 1.2rem;
    }

    .comparison-subtitle {
        font-size: 0.8rem;
    }

    .close-btn {
        width: 36px;
        height: 36px;
    }

    .comparison-body {
        padding: 1rem;
        gap: 1rem;
    }

    .comparison-viewer {
        min-height: 250px;
    }

    .comparison-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
        padding: 1rem;
    }

    .stat-pill::after {
        content: none;
    }

    /* Improved comparison labels positioning for mobile */
    .comparison-labels {
        bottom: 1rem;
        padding: 0 1rem;
    }

    .comp-badge {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Larger touch target for slider handle */
    .handle-circle {
        width: 44px;
        height: 44px;
        border-width: 3px;
    }

    .handle-circles-inner div {
        height: 10px;
    }
}

@media (max-width: 480px) {
    .comparison-header {
        padding: 0.75rem 1rem;
    }

    .comparison-title-group h3 {
        font-size: 1rem;
    }

    .comparison-subtitle {
        display: none;
    }

    .comparison-body {
        padding: 0.75rem;
    }

    .comparison-viewer {
        min-height: 200px;
        border-radius: var(--radius-sm);
    }

    .comparison-labels {
        bottom: 0.75rem;
        padding: 0 0.75rem;
    }

    .comp-badge {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
    }

    .stat-pill .label {
        font-size: 0.65rem;
    }

    .stat-pill .value {
        font-size: 0.95rem;
    }

    /* Increase touch target */
    .handle-circle {
        width: 48px;
        height: 48px;
    }
}