/**
 * 产品比较页面样式
 * 基于megasig.com网站风格
 */

/* 页面基础样式 */
#comparison_wrapper {
    background-color: #f9f9f9;
    padding: 40px 0 80px;
    min-height: 600px;
}

/* 返回选择页面链接 */
.back-to-select {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 8px;
    margin-bottom: 20px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #0a4480;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.back-link:hover {
    color: #083d6e;
    text-decoration: underline;
}

.back-link .fyicon {
    font-size: 12px;
}

.compare-info {
    font-size: 14px;
    color: #666;
}

.compare-info strong {
    color: #0a4480;
}

/* 分类筛选 - 京东淘宝风格 */
.jd-category-filter {
    background-color: #fff;
    border: 1px solid #ececec;
    margin-bottom: 20px;
}

.jd-category-filter .category-header {
    padding: 15px 20px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ececec;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.jd-category-filter .category-header .fyicon {
    font-size: 18px;
    color: #0a4480;
}

.jd-category-filter .category-body {
    display: flex;
    min-height: 200px;
}

/* 左侧一级分类 */
.category-level1 {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid #ececec;
    background-color: #fafafa;
}

.category-level1 .level1-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    color: #666;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.category-level1 .level1-item:hover {
    background-color: #fff;
    color: #0a4480;
}

.category-level1 .level1-item.active {
    background-color: #fff;
    color: #0a4480;
    font-weight: bold;
    border-left: 3px solid #0a4480;
}

.category-level1 .level1-item .fyicon {
    font-size: 12px;
    opacity: 0.5;
}

.category-level1 .level1-item.active .fyicon {
    opacity: 1;
}

/* 右侧二三级分类面板 */
.category-level2-panel {
    flex: 1;
    padding: 15px 20px;
    height: 300px;
    overflow-y: auto;
}

.category-level2-panel .panel-inner {
    display: inline-block;
}

.category-level2-panel .level2-group {
    display: none;
}

.category-level2-panel .level2-group.active {
    display: block;
}

/* 二级分类 */
.level2-group .level2-item {
    margin-bottom: 15px;
}

.level2-group .level2-link {
    display: inline-block;
    padding: 6px 15px;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.level2-group .level2-link:hover {
    background-color: #0a4480;
    color: #fff;
}

.level2-group .level2-link.active {
    background-color: #0a4480;
    color: #fff;
    font-weight: bold;
}

/* 三级分类 */
.level3-list {
    padding-left: 15px;
    margin-bottom: 10px;
    display: inline;
}

.level3-list .level3-link {
    display: inline-block;
    padding: 4px 12px;
    color: #999;
    text-decoration: none;
    font-size: 13px;
    margin-right: 8px;
    margin-bottom: 5px;
    border: 1px solid #eee;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.level3-list .level3-link:hover {
    color: #0a4480;
    border-color: #0a4480;
}

.level3-list .level3-link.active {
    color: #0a4480;
    border-color: #0a4480;
    background-color: #deebf7;
    font-weight: 500;
}

/* 移除旧的分类筛选样式 */
.category-filter {
    display: none;
}

/* 产品选择器 */
.product-selector {
    background-color: #fff;
    border: 1px solid #ececec;
    padding: 25px;
    margin-bottom: 20px;
}

.product-selector .selector-title {
    font-size: 16px;
    color: #222;
    font-weight: bold;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.product-selector .selector-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.product-selector .selector-item {
    position: relative;
    border: 2px solid #ececec;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.product-selector .selector-item:hover {
    border-color: #0a4480;
    box-shadow: 0 2px 8px rgba(10, 68, 128, 0.1);
}

.product-selector .selector-item.selected {
    border-color: #0a4480;
    background-color: #f0f7ff;
}

.product-selector .selector-item input[type="checkbox"] {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.product-selector .selector-item .item-image {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    overflow: hidden;
}

.product-selector .selector-item .item-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-selector .selector-item .item-name {
    font-size: 14px;
    color: #222;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 5px;
}

.product-selector .selector-item .item-model {
    font-size: 12px;
    color: #999;
}

/* 比较容器 */
.comparison-container {
    background-color: #fff;
    border: 1px solid #ececec;
}

/* 工具栏 */
.comparison-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #ececec;
    background-color: #fff;
}

.comparison-toolbar .toolbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.comparison-toolbar .toolbar-left h2 {
    font-size: 20px;
    color: #222;
    font-weight: bold;
    margin: 0;
}

.comparison-toolbar .compare-count {
    font-size: 14px;
    color: #999;
}

.comparison-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.highlight-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    padding: 6px 12px;
    background-color: #f5f5f5;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.highlight-toggle:hover {
    background-color: #e8e8e8;
}

.highlight-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #0a4480;
}

.highlight-toggle input[type="checkbox"]:checked + span {
    color: #0a4480;
    font-weight: 500;
}

.btn-clear {
    padding: 8px 20px;
    font-size: 14px;
    color: #999;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.btn-clear:hover {
    color: #c00;
    border-color: #c00;
    background-color: #fff5f5;
}

/* 表格滚动容器 */
.table-scroll-container {
    position: relative;
}

/* 比较表格包装器 */
.comparison-table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.comparison-table-wrapper::-webkit-scrollbar {
    height: 10px;
}

.comparison-table-wrapper::-webkit-scrollbar-track {
    background-color: #f5f5f5;
    border-radius: 5px;
}

.comparison-table-wrapper::-webkit-scrollbar-thumb {
    background-color: #c0c0c0;
    border-radius: 5px;
}

.comparison-table-wrapper::-webkit-scrollbar-thumb:hover {
    background-color: #a0a0a0;
}

/* 底部滚动控制栏 */
.table-scroll-controls {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background: #f8f9fa;
    border-top: 1px solid #ececec;
    margin-top: 0;
}

.scroll-track-wrapper {
    width: 100%;
    max-width: 600px;
    padding: 0 20px;
}

.scroll-track {
    position: relative;
    height: 12px;
    background: #e8e8e8;
    border-radius: 6px;
    cursor: pointer;
}

.scroll-thumb {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    min-width: 60px;
    max-width: 100%;
    background: linear-gradient(180deg, #0a4480 0%, #1a5490 50%, #0a4480 100%);
    border-radius: 6px;
    cursor: grab;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(10, 68, 128, 0.3);
}

.scroll-thumb:hover {
    transform: scaleY(1.1);
    box-shadow: 0 2px 8px rgba(10, 68, 128, 0.4);
}

.scroll-thumb.dragging {
    cursor: grabbing;
    transform: scaleY(1.15);
    box-shadow: 0 3px 10px rgba(10, 68, 128, 0.5);
}

/* 工具栏滚动按钮组 */
.table-scroll-btns {
    display: none;
    align-items: center;
    gap: 2px;
    margin-right: 12px;
    padding: 4px;
    background: #f0f0f0;
    border-radius: 6px;
}

.table-scroll-btns.show {
    display: flex;
}

.scroll-btn {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #0a4480, #1a5490);
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.scroll-btn:hover {
    background: linear-gradient(135deg, #083d6e, #0a4480);
    transform: scale(1.05);
}

.scroll-btn:active {
    transform: scale(0.95);
}

.scroll-btn span {
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
}

/* 响应式 - 滚动按钮 */
@media (max-width: 768px) {
    .scroll-btn {
        width: 28px;
        height: 28px;
    }

    .scroll-btn span {
        font-size: 16px;
    }
}

/* 比较表格 */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 100%;
}

/* 表头 */
.comparison-table thead {
    background-color: #fafafa;
}

.comparison-table th {
    padding: 0;
    border: 1px solid #ececec;
    vertical-align: top;
}

/* 固定列（左侧属性列） */
.comparison-table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: #fff;
    width: 180px;
    min-width: 180px;
}

.comparison-table thead .sticky-col {
    background-color: #0a4480;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    padding: 20px;
    text-align: left;
}

/* 产品列 */
.comparison-table .product-col {
    width: 240px;
    min-width: 240px;
}

.product-header {
    position: relative;
    padding: 20px;
}

.product-header .product-image {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    overflow: hidden;
}

.product-header .product-image img {
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.product-header .product-image:hover img {
    transform: scale(1.05);
}

.product-header .product-info {
    text-align: center;
}

.product-header .product-name {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 8px;
    line-height: 1.4;
}

.product-header .product-name a {
    color: #222;
    text-decoration: none;
}

.product-header .product-name a:hover {
    color: #0a4480;
}

.product-header .product-model {
    font-size: 13px;
    color: #999;
}

.product-header .btn-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border: none;
    background-color: #f5f5f5;
    color: #999;
    font-size: 18px;
    line-height: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.product-header .btn-remove:hover {
    background-color: #c00;
    color: #fff;
}

/* 表格体 */
.comparison-table tbody td {
    padding: 15px 20px;
    border: 1px solid #ececec;
    vertical-align: top;
}

.comparison-table tbody .property-col {
    background-color: #f9f9f9;
    font-weight: bold;
    color: #444;
}

.comparison-table tbody .sticky-col {
    background-color: #f9f9f9;
}

.comparison-table tbody .value-col {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

.comparison-table tbody .value-col .no-data {
    color: #ccc;
}

.comparison-table tbody .cell-content {
    max-height: 200px;
    overflow-y: auto;
}

/* 规格行悬停效果 */
.comparison-table tbody .spec-row:hover td {
    background-color: #f5f9ff;
}

.comparison-table tbody .spec-row:hover .sticky-col {
    background-color: #e8f1fc;
}

/* ========== 性能参数比较样式 ========== */

/* 参数分组标题行 */
.spec-group-header {
    background-color: #f0f4f8 !important;
}

.spec-group-header td {
    border-top: 2px solid #0a4480 !important;
    border-bottom: none !important;
}

.spec-group-header .group-header-cell {
    padding: 12px 20px !important;
}

.spec-group-header .group-header-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: bold;
    color: #0a4480;
}

.spec-group-header .group-icon {
    width: 4px;
    height: 16px;
    background-color: #0a4480;
    border-radius: 2px;
}

/* 数值型参数行 */
.comparison-table tbody .numeric-spec .value-col {
    position: relative;
}

/* 数值柱状图 */
.value-bar-wrapper {
    position: relative;
    height: 6px;
    background-color: #e8e8e8;
    border-radius: 3px;
    margin-top: 18px;
    overflow: visible;
}

.value-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 3px;
    transition: width 0.3s ease;
    max-width: 100%;
}

/* 优劣标记 */
.value-badge {
    position: absolute;
    top: -18px;
    font-size: 12px;
    transform: translateX(-50%);
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
}

.best-badge {
    color: #fff;
    background-color: #4CAF50;
    right: 0;
}

.worst-badge {
    color: #fff;
    background-color: #FF9800;
    left: 0;
}

/* 最佳/最差值单元格高亮（受 show-best-worst 开关控制） */
.comparison-table.show-best-worst .best-value {
    background-color: rgba(76, 175, 80, 0.08) !important;
}

.comparison-table.show-best-worst .best-value .cell-content {
    color: #2e7d32;
    font-weight: 500;
}

.comparison-table.show-best-worst .worst-value {
    background-color: rgba(255, 152, 0, 0.08) !important;
}

.comparison-table.show-best-worst .worst-value .cell-content {
    color: #e65100;
}

/* 优劣标记显示/隐藏控制 */
.comparison-table .best-value .value-badge,
.comparison-table .worst-value .value-badge {
    display: none;
}

.comparison-table.show-best-worst .best-value .value-badge.best-badge,
.comparison-table.show-best-worst .worst-value .value-badge.worst-badge {
    display: inline-block;
}

/* 柱状图显示/隐藏控制 */
.comparison-table .numeric-spec .value-bar-wrapper {
    display: none;
}

.comparison-table.show-barchart .numeric-spec .value-bar-wrapper {
    display: block;
}

/* 差异高亮 */
.comparison-table.highlight-differences .has-diff .property-name {
    color: #0a4480;
    font-weight: bold;
}

.comparison-table.highlight-differences .diff-value {
    background-color: #fff8e1;
}

.comparison-table.highlight-differences .has-diff:hover .diff-value {
    background-color: #ffecb3;
}

/* 操作按钮行 */
.comparison-table .action-row td {
    padding: 20px;
    background-color: #fafafa;
}

.comparison-table .action-col {
    text-align: center;
}

.comparison-table .action-col a {
    display: inline-block;
    padding: 8px 16px;
    margin: 0 5px;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.comparison-table .btn-view {
    color: #0a4480;
    border: 1px solid #0a4480;
    background-color: #fff;
}

.comparison-table .btn-view:hover {
    color: #fff;
    background-color: #0a4480;
}

.comparison-table .btn-inquiry {
    color: #fff;
    border: 1px solid #0a4480;
    background-color: #0a4480;
}

.comparison-table .btn-inquiry:hover {
    background-color: #083d6e;
    border-color: #083d6e;
}

/* 固定底部产品导航 */
.sticky-product-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #fff;
    border-top: 2px solid #0a4480;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 999;
}

.sticky-product-nav.show {
    transform: translateY(0);
}

.sticky-product-nav .nav-content {
    max-width: 1300px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    align-items: center;
}

.sticky-product-nav .nav-label {
    font-size: 14px;
    color: #666;
    font-weight: bold;
    margin-right: 20px;
    white-space: nowrap;
}

.sticky-product-nav .nav-products {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow-x: auto;
}

.sticky-product-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 15px;
    background-color: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.sticky-product-nav .nav-item:hover {
    background-color: #e8e8e8;
    border-color: #0a4480;
}

.sticky-product-nav .nav-item.active {
    background-color: #0a4480;
    border-color: #0a4480;
}

.sticky-product-nav .nav-item.active img,
.sticky-product-nav .nav-item.active span {
    opacity: 1;
}

.sticky-product-nav .nav-item.active span {
    color: #fff;
}

.sticky-product-nav .nav-item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.sticky-product-nav .nav-item span {
    font-size: 13px;
    color: #444;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sticky-product-nav .nav-empty {
    padding: 10px 20px;
    color: #999;
    font-size: 13px;
}

/* 表格列高亮 */
.comparison-table th.highlight-col,
.comparison-table td.highlight-col {
    background-color: rgba(10, 68, 128, 0.1) !important;
    box-shadow: inset 0 0 0 2px rgba(10, 68, 128, 0.3);
}

.comparison-table th.highlight-col {
    background-color: rgba(10, 68, 128, 0.25) !important;
}

.comparison-table td.highlight-col {
    background-color: rgba(10, 68, 128, 0.08) !important;
}

/* 产品移除动画 */
.comparison-table th,
.comparison-table td {
    transition: opacity 0.3s, transform 0.3s;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    background-color: #fff;
    border: 1px solid #ececec;
}

.empty-state .empty-icon {
    font-size: 80px;
    color: #ddd;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    color: #444;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 14px;
    color: #999;
    margin-bottom: 30px;
}

.empty-state .btn-browse {
    display: inline-block;
    padding: 12px 40px;
    font-size: 16px;
    color: #fff;
    background-color: #0a4480;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.empty-state .btn-browse:hover {
    background-color: #083d6e;
}

/* 响应式设计 */
/* 响应式设计 - 京东淘宝风格分类 */
@media only screen and (max-width: 1024px) {
    .category-filter {
        flex-direction: column;
    }

    .category-filter .filter-label {
        margin-right: 0;
        margin-bottom: 15px;
    }

    .product-selector .selector-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .comparison-toolbar {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .comparison-toolbar .toolbar-right {
        flex-wrap: wrap;
    }

    .sticky-product-nav {
        display: none;
    }

    .comparison-table .product-col {
        width: 220px;
        min-width: 220px;
    }

    /* 分类选择器响应式 */
    .jd-category-filter .category-body {
        flex-direction: column;
    }

    .jd-category-filter .category-level1 {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ececec;
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        padding: 10px;
    }

    .jd-category-filter .category-level1 .level1-item {
        padding: 8px 15px;
        border: 1px solid #ddd;
        border-radius: 4px;
        flex: 0 0 auto;
    }

    .jd-category-filter .category-level1 .level1-item.active {
        border-color: #0a4480;
        background-color: #0a4480;
        color: #fff;
        border-left: 1px solid #0a4480;
    }

    .jd-category-filter .category-level2-panel {
        padding: 15px;
    }
}

@media only screen and (max-width: 768px) {
    #comparison_wrapper {
        padding: 20px 0 40px;
    }

    .category-filter,
    .product-selector,
    .comparison-container {
        margin-left: 15px;
        margin-right: 15px;
    }

    .product-selector .selector-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .comparison-table .sticky-col {
        width: 120px;
        min-width: 120px;
    }

    .comparison-table .product-col {
        width: 200px;
        min-width: 200px;
    }

    .product-header {
        padding: 15px;
    }

    .product-header .product-image {
        height: 120px;
    }

    .comparison-table tbody td {
        padding: 12px 15px;
    }

    .comparison-toolbar .toolbar-right {
        gap: 10px;
    }

    .highlight-toggle {
        padding: 5px 10px;
        font-size: 12px;
    }

    .jd-category-filter .category-header {
        font-size: 14px;
        padding: 12px 15px;
    }

    .level2-group .level2-link {
        font-size: 13px;
        padding: 5px 12px;
    }

    .level3-list .level3-link {
        font-size: 12px;
        padding: 3px 10px;
    }
}

@media only screen and (max-width: 480px) {
    .product-selector .selector-list {
        grid-template-columns: 1fr;
    }

    .comparison-toolbar .toolbar-right {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .comparison-table .action-col a {
        display: block;
        margin: 5px 0;
    }

    .comparison-table .product-col {
        width: 180px;
        min-width: 180px;
    }

    .jd-category-filter .category-level1 {
        padding: 8px;
    }

    .jd-category-filter .category-level1 .level1-item {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* 打印样式 */
@media print {
    #header-bg,
    #prods_banners,
    .jd-category-filter,
    .product-selector,
    .comparison-toolbar,
    .sticky-product-nav,
    #footer {
        display: none !important;
    }

    .comparison-table-wrapper {
        overflow: visible;
    }

    .comparison-table {
        min-width: 100% !important;
    }

    .comparison-table .sticky-col {
        position: static;
    }

    .value-bar-wrapper,
    .value-badge {
        display: none !important;
    }
}
