/* --- Main Container --- */
.compare-page-container {
    background-color: #f8f9fa;
}

/* --- Comparison Table Structure --- */
.comparison-table-container {
    width: 100%;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
    background-color: #ffffff;
}

.compare-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f9fafb;
}

.compare-row {
    display: flex;
    border-bottom: 1px solid var(--bg-soft);
}

.compare-body .compare-row:last-child {
    border-bottom: none;
}

.compare-cell {
    padding: 1rem;
    flex-grow: 1;
    flex-basis: 0;
    min-width: 0;
}

.device-spec-cell {
    text-align: center;
}

.spec-label-cell {
    flex-grow: 0.5;
    flex-shrink: 0;
    font-weight: 600;
    background-color: #f9fafb;
    border-right: 1px solid #e5e7eb;
}

.device-header-cell {
    text-align: center;
    position: relative;
    border-left: 1px solid #e5e7eb;
}

.device-header-cell h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-header-cell:first-of-type {
    border-left: none;
}

.device-image {
    width: 80px;
    height: 80px;
    aspect-ratio: 1/1;
    object-fit: cover;
    margin: 0 auto 0.5rem;
    border-radius: 0.5rem;
}

.device-name {
    font-size: 1rem;
    font-weight: 700;
    color: #11182c;
}

.device-link {
    text-decoration: none;
}

.remove-device-btn {
    position: absolute;
    top: 0.5rem;
    right: 2rem;
    max-width: 1.5rem;
    max-height: 1.5rem;
    border-radius: 9999px;
    background-color: #e5e7eb;
    color: #4b5563;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    padding: 0;
    min-width: 1.5rem;
    min-height: 1.5rem;
}

.remove-device-btn i {
    display: block;
    line-height: normal;
    font-size: 0.685rem;
    padding-top: 1px;
    border-radius: 9999px;
}

.remove-device-btn:hover {
    background-color: #ef4444;
    color: #ffffff;
}

.device-spec-cell {
    border-left: 1px solid #e5e7eb;
}

.device-spec-cell:first-of-type {
    border-left: none;
}

/* --- Highlighting Differences --- */
.highlight-differences .compare-row:not(.has-difference) {
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.highlight-differences .compare-row:not(.has-difference).is-different {
    opacity: unset;
}

.highlight-differences .compare-row.has-difference {
    background-color: #eff6ff;
    /* blue-50 */
}


.compare-body .device-spec-cell {
    box-sizing: border-box;
    border-bottom: 1px solid var(--border);
}

.device-footer-link {
    display: block;
    text-align: center;
    min-width: 100%;
    padding: 8px 16px;
    background-color: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
}

.device-footer-link:hover {
    background-color: var(--bg-main);
    color: var(--text-secondary);
}

/* === Buttons === */
.switch-btn {
    display: block;
    background-color: #3b82f6;
    color: #000;
    border: none;
    padding: 0;
    border-radius: 0.375rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    max-width: 250px;
    margin-right: auto;
    margin-left: auto;
}

.switch-btn span {
    display: inline-block;
    color: gray;
    margin: 0;
    padding: 0.75rem 1rem 0.75rem 1rem;
    font-size: 1rem;
    cursor: pointer;
    min-width: 100%;
}

.switch-btn span:hover {
    color: #3b82f6;
}

.switch-btn:hover {
    background-color: #2563eb;
}

.btn-outline {
    background-color: transparent;
    color: #3b82f6;
    border: 1px solid #3b82f6;
}

.btn-outline:hover {
    background-color: #eff6ff;
}

/* --- Mobile Responsive View --- */
@media (max-width: 767px) {
    .compare-header {
        overflow-x: auto;
        -ms-overflow-style: none;
        /* IE and Edge */
        scrollbar-width: none;
        /* Firefox */
        scroll-snap-align: start;
        scroll-margin: 0;
        box-sizing: border-box;
        padding: 0;
    }

    .compare-header::-webkit-scrollbar {
        display: none;
        /* Chrome, Safari, and Opera */
    }

    .compare-header .compare-row {
        justify-content: space-between;
        gap: 5px;
        min-width: 100%;
        display: inline-flex;
    }

    .spec-label-cell {
        display: none;
        /* Hide the feature label column header on mobile */
    }

    .device-header-cell {
        flex: 0 0 auto;
        /* Don't grow, don't shrink */
        width: 105px;
        padding: 0.5rem;
        border: none;
        border-bottom: 2px solid transparent;
        cursor: pointer;
        transition: border-color 0.2s;
        padding-left: 2px;
    }

    .device-header-cell.active::after {
        display: block;
        content: ' ';
        max-width: 55px;
        min-height: 2px;
        margin-top: 10px;
        border-bottom: 2px solid #2563eb;
        /* blue-600 */
        animation: growWidth 0.5s alternate;
        /* Apply animation */
    }

    @keyframes growWidth {
        0% {
            width: 0;
        }

        100% {
            width: 100%;
        }
    }

    .device-image {
        aspect-ratio: 1/1;
        object-fit: cover;
    }

    .device-name {
        font-size: 0.785rem;
    }

    .compare-body .compare-row {
        flex-direction: row;
        font-size: 0.785rem;
    }

    .compare-body .spec-label-cell {
        display: block;
        /* Show the label again */
        max-width: 120px;
        min-width: 120px;
        border-right: none;
        padding: 0.5rem;
        border-right: 2px solid #e5e7eb;
    }


    .spec-label-cell.device-footer-label {
        display: none;
    }

    .compare-body .device-spec-cell {
        display: none;
        /* Hide all spec cells by default */
        border-left: none;
        padding: 0.5rem;
        padding-left: 1rem;
        /* Indent for clarity */
        hyphens: auto;
    }

    .compare-body .device-spec-cell.active {
        display: block;
        /* Show only the active one */
    }


    .remove-device-btn {
        right: 1rem;
    }

    .device-footer-row {
        background-color: #f2f2f2;
    }

    .device-footer-link {
        margin-left: -0.5rem;
    }
}