/* ==================== 商品对比页（小米/华为商城式简洁电商风）==================== */
/* 完整对比表格：图片/名称/售价/市场价/货号/品牌/库存/重量/单位/免运费/标签/简介
   样式自包含，不依赖 products.css */

/* ---------- 页面容器 ---------- */
.products-page.compare-page {
    max-width: var(--container);
    margin: 0 auto;
    padding: 16px 0 40px;
}

/* ---------- 对比页头部 ---------- */
.compare-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.compare-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.compare-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
}
.compare-count-info {
    font-size: 13px;
    color: var(--text-3);
}
.compare-toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 继续购物链接按钮 */
.btn-compare-link {
    padding: 8px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: var(--card);
    color: var(--brand);
    font-size: 13px;
    text-decoration: none;
    transition: all var(--fast);
}
.btn-compare-link:hover {
    border-color: var(--brand);
    background: var(--brand-light);
}

/* 清空对比按钮（危险操作，红色描边） */
.btn-clear-all {
    padding: 8px 18px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-s);
    background: var(--card);
    color: var(--danger);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--fast);
}
.btn-clear-all:hover {
    background: #fdecec;
}

/* ---------- 空状态 ---------- */
.compare-empty-state {
    text-align: center;
    padding: 70px 20px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-s);
}
.compare-empty-state svg {
    color: var(--text-3);
    margin-bottom: 16px;
}
.compare-empty-state .empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 6px 0;
}
.compare-empty-state .empty-desc {
    font-size: 13px;
    color: var(--text-3);
    margin: 0 0 20px 0;
}
.btn-go-shop {
    display: inline-block;
    padding: 0 32px;
    height: 40px;
    line-height: 40px;
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius-s);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--fast);
}
.btn-go-shop:hover {
    background: var(--brand-hover);
    color: #fff;
}

/* ---------- 对比表格容器（横向滚动） ---------- */
.compare-table-wrap {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-s);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.compare-table-full {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}
.compare-table-full th,
.compare-table-full td {
    border-bottom: 1px solid var(--line-2);
    padding: 16px 14px;
    text-align: center;
    vertical-align: middle;
}

/* 属性标签列（首列，横向滚动时粘性保持可见） */
.compare-table-full th.attr-col,
.compare-table-full td.attr-col {
    width: 120px;
    min-width: 120px;
    background: var(--bg);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    text-align: left;
    padding-left: 20px;
    position: sticky;
    left: 0;
    z-index: 1;
}

/* ---------- 表头商品列 ---------- */
.compare-table-full th.product-col {
    width: 200px;
    min-width: 200px;
    padding: 20px 14px;
    position: relative;
}
.compare-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-3);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: all var(--fast);
    display: flex;
    align-items: center;
    justify-content: center;
}
.compare-remove-btn:hover {
    background: var(--danger);
    color: #fff;
    transform: rotate(90deg);
}

.compare-product-img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--radius-s);
    border: 1px solid var(--line-2);
    margin-bottom: 10px;
}
.compare-no-img {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-s);
    background: var(--bg);
    border: 1px solid var(--line-2);
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
}
.compare-no-img svg {
    width: 36px;
    height: 36px;
}

.compare-product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 8px;
    /* 长名称限制 2 行，保持表格整齐 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.compare-product-name a {
    color: var(--text);
    text-decoration: none;
    transition: color var(--fast);
}
.compare-product-name a:hover {
    color: var(--brand);
}

.btn-view-detail {
    display: inline-block;
    padding: 6px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: var(--card);
    color: var(--brand);
    font-size: 12px;
    text-decoration: none;
    transition: all var(--fast);
}
.btn-view-detail:hover {
    border-color: var(--brand);
    background: var(--brand-light);
}

/* ---------- 数据单元格 ---------- */
.compare-table-full td.data-cell {
    font-size: 13px;
    color: var(--text);
}
.compare-table-full td.data-cell .market-price {
    color: var(--text-3);
    text-decoration: line-through;
    font-size: 12px;
    font-weight: 400;
    display: block;
    margin-top: 2px;
}
.compare-table-full td.data-cell .stock-in {
    color: var(--success);
    font-weight: 600;
}
.compare-table-full td.data-cell .stock-out {
    color: var(--danger);
    font-weight: 600;
}
.compare-table-full td.data-cell .tag-yes {
    color: var(--success);
    font-weight: 600;
}
.compare-table-full td.data-cell .tag-no {
    color: var(--text-3);
}
.compare-table-full td.data-cell .dash {
    color: var(--text-3);
}
.compare-table-full td.data-cell .summary-cell {
    font-size: 12px;
    color: var(--text-2);
    line-height: 1.5;
    max-width: 200px;
    text-align: left;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.compare-table-full td.data-cell .tag-chip {
    display: inline-block;
    padding: 2px 8px;
    background: var(--brand-light);
    color: var(--brand);
    border-radius: 999px;
    font-size: 11px;
    margin: 2px;
}

/* ---------- 加载动画 ---------- */
.loading-spinner {
    text-align: center;
    padding: 60px;
    color: var(--text-3);
    font-size: 14px;
}
.loading-spinner::before {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .products-page.compare-page { padding: 8px 0 24px; }
    .compare-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .compare-header h1 { font-size: 20px; }
    /* 工具条允许换行，防止窄屏溢出 */
    .compare-toolbar {
        flex-wrap: wrap;
        gap: 10px;
        width: 100%;
    }
    .compare-toolbar-actions {
        flex: 1;
        justify-content: flex-end;
    }
    .btn-compare-link,
    .btn-clear-all {
        min-height: 40px;
        padding: 9px 14px;
        display: inline-flex;
        align-items: center;
    }
    .compare-empty-state { padding: 48px 16px; }
    .compare-product-img,
    .compare-no-img {
        width: 72px;
        height: 72px;
    }
    /* 表格横向滚动：收紧单元格留白，属性列收窄并提示可滑动 */
    .compare-table-full th,
    .compare-table-full td {
        padding: 12px 10px;
    }
    .compare-table-full th.attr-col,
    .compare-table-full td.attr-col {
        width: 92px;
        min-width: 92px;
        padding-left: 12px;
        font-size: 12px;
    }
    .compare-table-full th.product-col {
        min-width: 150px;
        padding: 14px 10px;
    }
    /* 移除按钮加大触摸目标 */
    .compare-remove-btn {
        width: 30px;
        height: 30px;
        top: 6px;
        right: 6px;
        font-size: 17px;
    }
    .compare-table-full td.data-cell .summary-cell {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .compare-table-full th.attr-col,
    .compare-table-full td.attr-col {
        width: 78px;
        min-width: 78px;
        padding-left: 10px;
    }
    .compare-toolbar-actions {
        justify-content: stretch;
    }
    .btn-compare-link,
    .btn-clear-all {
        flex: 1;
        justify-content: center;
    }
}
