/**
 * Compare Page — هماهنگ با site-theme
 */

.compare-section {
    /* navbar is fixed in this theme */
    padding: 140px 0 40px;
    min-height: 35vh;
}

.compare-section .container {
    max-width: 1400px !important;
    width: 100%;
}

.compare-section .section-header {
    text-align: center;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: linear-gradient(
        180deg,
        rgba(var(--c-primary-rgb, 109, 40, 217), 0.10),
        rgba(255, 255, 255, 0.92)
    );
    border: 1px solid rgba(var(--c-primary-rgb, 109, 40, 217), 0.18);
    border-radius: var(--radius, 14px);
    box-shadow: var(--shadow, 0 2px 16px rgba(109, 40, 217, 0.08));
    position: relative;
    overflow: hidden;
}

/* kill any global decorative lines */
.compare-section .section-header::before,
.compare-section .section-header::after {
    content: none !important;
    display: none !important;
}

/* force-remove any divider line from global styles */
.compare-section .section-title,
.compare-section .section-header .section-title {
    padding-bottom: 0 !important;
    border-bottom: none !important;
    box-shadow: none !important;
    background-image: none !important;
}

.compare-section .section-title::before,
.compare-section .section-title::after,
.compare-section .section-header .section-title::before,
.compare-section .section-header .section-title::after {
    content: none !important;
    display: none !important;
}

.compare-section .section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--c-dark, #1e1b4b);
    margin: 0 0 6px;
}

.compare-section .section-description {
    font-size: 0.95rem;
    color: #6b7280;
    margin: 0;
}

/* Empty state */
.compare-section .empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 44px 22px;
    background: var(--c-card, #fff);
    border: 1px solid var(--c-border, #ede9fe);
    border-radius: var(--radius, 14px);
    box-shadow: var(--shadow, 0 2px 16px rgba(109, 40, 217, 0.08));
    max-width: 720px;
    margin: 0 auto;
}

.compare-section .empty-state h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--c-dark, #1e1b4b);
    margin: 16px 0 8px;
}

.compare-section .empty-state p {
    color: #6b7280;
    margin: 0 0 20px;
    font-size: 0.95rem;
    line-height: 1.7;
}

.compare-container {
    margin-top: 8px;
}

.compare-actions {
    display: flex;
    direction: rtl;
    justify-content: flex-start; /* in RTL this aligns to the right */
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: var(--c-card, #fff);
    border: 1px solid var(--c-border, #ede9fe);
    border-radius: var(--radius, 14px);
    box-shadow: var(--shadow, 0 2px 16px rgba(109, 40, 217, 0.08));
}

.compare-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 10px;
}

.compare-actions .btn-outline-danger {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fff;
}

.compare-actions .btn-outline-danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
}

.compare-actions .btn-outline-primary {
    color: var(--c-primary, #6d28d9);
    border-color: rgba(var(--c-primary-rgb, 109, 40, 217), 0.35);
    background: #fff;
}

.compare-actions .btn-outline-primary:hover {
    background: rgba(var(--c-primary-rgb, 109, 40, 217), 0.06);
}

/* Table wrapper */
.compare-section .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius, 14px);
    border: 1px solid var(--c-border, #ede9fe);
    background: var(--c-card, #fff);
    box-shadow: var(--shadow, 0 2px 16px rgba(109, 40, 217, 0.08));
}

.compare-table {
    width: 100%;
    min-width: 760px;
    /* separate + spacing:0 لازم است تا position:sticky روی سلول‌ها درست کار کند */
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
}

.compare-table th,
.compare-table td {
    padding: 12px 12px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid var(--c-border, #ede9fe);
    font-size: 0.9rem;
    background: #fff;
    position: relative;
    z-index: 1;
}

.compare-table thead th {
    background: #faf9ff;
    font-weight: 600;
    vertical-align: top;
    border-bottom: 2px solid var(--c-border, #ede9fe);
}

.compare-table thead .feature-column {
    vertical-align: middle;
    text-align: center !important;
    padding: 12px 10px;
    /* پس‌زمینه کاملاً مات — گرادیان شفاف باعث دیده شدن محصولات زیر ستون می‌شد */
    background: #f3f0ff !important;
    color: var(--c-dark, #1e1b4b);
    z-index: 6;
}

.compare-table thead .feature-column::after {
    content: "مشخصات";
    display: block;
    margin-top: 6px;
    font-weight: 500;
    font-size: 12px;
    color: rgba(17, 24, 39, 0.55);
}

.compare-table tbody tr:last-child td {
    border-bottom: none;
}

.compare-table tbody tr:nth-child(even) td:not(.feature-name) {
    background: #faf9ff;
}

.feature-column,
.feature-name {
    text-align: right !important;
    font-weight: 600;
    color: var(--c-dark, #1e1b4b);
    background: #faf9ff !important;
    background-clip: padding-box;
    min-width: 120px;
    width: 130px;
    position: sticky;
    right: 0;
    z-index: 5;
    /* سایه سمت چپ ستون چسبان تا محتوای اسکرول‌شده دیده نشود */
    box-shadow: -8px 0 14px -6px rgba(15, 23, 42, 0.18);
}

/* لایه مات پشت متن ستون ویژگی — جلوگیری از تداخل با کارت محصول */
.feature-column::before,
.feature-name::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: -10px;
    background: inherit;
    z-index: -1;
    pointer-events: none;
}

.product-column {
    min-width: 200px;
    max-width: 260px;
    width: 220px;
    z-index: 1;
    background: #fff !important;
    overflow: hidden;
}

.compare-table tbody td:not(.feature-name) {
    overflow: hidden;
}

/* Product card in header */
.product-card-compare {
    position: relative;
    padding: 10px 8px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.remove-product-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 28px;
    height: 28px;
    border: 1px solid var(--c-border, #ede9fe);
    background: #fff;
    color: #9ca3af;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1;
    font-size: 14px;
    padding: 0;
}

.remove-product-btn:hover {
    color: #dc2626;
    border-color: #fecaca;
    background: #fef2f2;
}

.product-card-compare .product-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin: 0;
}

.product-card-compare .product-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
    line-height: 1.5;
    min-height: 2.6em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
}

.product-card-compare .product-price {
    margin: 0;
    width: 100%;
}

.product-card-compare .old-price {
    display: block;
    font-size: 0.8rem;
    color: #9ca3af;
    text-decoration: line-through;
    margin-bottom: 2px;
}

.product-card-compare .current-price {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--c-primary, #6d28d9);
}

.product-card-compare .btn-view-product {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: var(--c-primary, #6d28d9);
    border: none;
    border-radius: 10px;
    text-decoration: none;
    transition: background 0.2s;
}

.product-card-compare .btn-view-product:hover {
    background: var(--c-primary-dark, #4c1d95);
    color: #fff;
}

/* Badges */
.compare-table .badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.compare-table .badge-success {
    background: #d1fae5;
    color: #065f46;
}

.compare-table .badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* Loading */
.compare-section .loading-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
}

.compare-section .spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--c-border, #ede9fe);
    border-top-color: var(--c-primary, #6d28d9);
    border-radius: 50%;
    animation: compare-spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes compare-spin {
    to { transform: rotate(360deg); }
}

.compare-section .loading-state p {
    font-size: 0.95rem;
    color: #6b7280;
    margin: 0;
}

/* Hide sticky compare bar on this page */
body.compare-page #compare-bar {
    display: none !important;
}

/* Print */
@media print {
    .compare-actions,
    .breadcrumb-container,
    .remove-product-btn,
    #compare-bar {
        display: none !important;
    }

    .compare-section .table-responsive {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .compare-section {
        padding: 110px 0 28px;
    }

    .compare-section .section-header {
        padding: 12px 12px;
        margin-bottom: 12px;
    }

    .compare-section .section-title {
        font-size: 1.25rem;
    }

    .compare-section .table-responsive {
        margin-inline: -4px;
        border-radius: 12px;
        /* prevent sticky overlap painting issues */
        isolation: isolate;
    }

    .compare-table {
        min-width: 0;
        width: max-content;
        table-layout: fixed;
    }

    .compare-table th,
    .compare-table td {
        padding: 10px 8px;
        font-size: 0.78rem;
    }

    /* Hide decorative "مشخصات" label that overlaps product titles on narrow screens */
    .compare-table thead .feature-column::after {
        display: none !important;
        content: none !important;
    }

    .feature-column,
    .feature-name {
        min-width: 72px !important;
        width: 72px !important;
        max-width: 80px;
        font-size: 0.72rem !important;
        padding: 8px 6px !important;
        line-height: 1.35;
        background: #faf9ff !important;
        box-shadow: -10px 0 16px -8px rgba(15, 23, 42, 0.22);
        z-index: 5 !important;
        word-break: break-word;
    }

    .compare-table thead .feature-column {
        font-size: 0.75rem !important;
        vertical-align: middle;
        background: #f3f0ff !important;
        z-index: 6 !important;
    }

    .product-column {
        min-width: 148px !important;
        max-width: 160px !important;
        width: 152px !important;
        vertical-align: top;
        background: #fff !important;
        position: relative;
        z-index: 1 !important;
    }

    .compare-table tbody td:not(.feature-name) {
        z-index: 1 !important;
        background: #fff;
    }

    .compare-table tbody tr:nth-child(even) td:not(.feature-name) {
        background: #faf9ff;
    }

    .product-card-compare {
        padding: 8px 4px 2px;
        gap: 6px;
        overflow: hidden;
    }

    .product-card-compare .product-image {
        width: 72px;
        height: 72px;
    }

    .product-card-compare .product-name {
        font-size: 0.72rem;
        line-height: 1.45;
        min-height: 2.9em;
        max-height: 2.9em;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        word-break: break-word;
        width: 100%;
    }

    .product-card-compare .product-price {
        font-size: 0.75rem;
    }

    .product-card-compare .btn-view-product {
        font-size: 0.72rem;
        padding: 6px 8px;
        white-space: nowrap;
    }

    .remove-product-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
        top: 2px;
        left: 2px;
    }

    .compare-actions {
        justify-content: flex-start; /* right in RTL */
    }
}

@media (max-width: 400px) {
    .feature-column,
    .feature-name {
        min-width: 64px !important;
        width: 64px !important;
        font-size: 0.68rem !important;
    }

    .product-column {
        min-width: 136px !important;
        max-width: 148px !important;
        width: 140px !important;
    }
}

@media (min-width: 1400px) {
    .compare-section .container {
        max-width: 1600px;
    }
}
