/**
 * 产品对比功能样式
 */

/* ========== 对比悬浮栏 ========== */
.compare-bar {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transition: bottom 0.3s ease;
}

.compare-bar.show {
    bottom: 0;
}

.compare-bar.collapsed .compare-bar-body {
    display: none;
}

.compare-bar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
}

.compare-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.compare-bar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.compare-bar-header .btn-icon {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 18px;
    padding: 5px 10px;
    transition: color 0.3s;
}

.compare-bar-header .btn-icon:hover {
    color: #333;
}

.compare-bar-body {
    padding: 15px 20px;
}

.compare-bar-items {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.compare-bar-items::-webkit-scrollbar {
    height: 6px;
}

.compare-bar-items::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.compare-bar-items::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.compare-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    position: relative;
    transition: all 0.3s;
}

.compare-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.compare-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 8px;
}

.compare-item .item-name {
    font-size: 13px;
    color: #333;
    text-align: center;
    line-height: 1.3;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.compare-item-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    border: 2px solid white;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.compare-item-remove:hover {
    background: #c82333;
    transform: scale(1.1);
}

.compare-bar-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
}

.compare-bar .text-muted {
    color: #999;
    text-align: center;
    padding: 20px;
}

/* ========== 对比页面 ========== */
.compare-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toolbar-left {
    flex: 1;
}

.toolbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.toolbar-title i {
    color: var(--primary-color);
    font-size: 22px;
}

/* 保留旧的h2样式以兼容 */
.toolbar-left h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.toolbar-right {
    display: flex;
    gap: 10px;
}

.btn-filter,
.btn-export,
.btn-share {
    padding: 10px 20px;
    border: 2px solid var(--border-light);
    background: var(--bg-white);
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-filter:hover,
.btn-export:hover,
.btn-share:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-alpha-10);
    transform: translateY(-1px);
}

.btn-filter.active {
    background: var(--primary-color);
    color: var(--text-white);
    border-color: var(--primary-color);
}

/* 对比表格 */
.compare-table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.compare-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed; /* 使用固定表格布局 */
}

.compare-table thead {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.compare-table thead tr {
    background: #f8f9fa;
}

.compare-table th,
.compare-table td {
    padding: 16px;
    text-align: left;
    border: 1px solid #e0e0e0;
}

.compare-table th {
    font-weight: 600;
    color: #333;
}

/* 产品头部 */
.product-header {
    background: #f8f9fa;
}

.product-header th {
    text-align: center;
    vertical-align: top;
    min-width: 200px;
}

/* 动态调整列宽 */
.compare-table th:first-child,
.compare-table td:first-child {
    width: 200px; /* 第一列固定宽度 */
    min-width: 150px;
}

/* 产品列平均分配剩余宽度 */
.compare-table.products-2 th:not(:first-child),
.compare-table.products-2 td:not(:first-child) {
    width: calc((100% - 200px) / 2);
}

.compare-table.products-3 th:not(:first-child),
.compare-table.products-3 td:not(:first-child) {
    width: calc((100% - 200px) / 3);
}

.compare-table.products-4 th:not(:first-child),
.compare-table.products-4 td:not(:first-child) {
    width: calc((100% - 200px) / 4);
}

.product-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.product-image {
    width: 150px;
    height: 150px;
    object-fit: contain;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.product-series {
    font-size: 13px;
    color: #666;
    text-align: center;
}

/* 参数行 */
.param-name {
    width: 200px;
    min-width: 150px;
    font-weight: 500;
    background: #fafafa;
}

.param-group-header {
    background: #e3f2fd;
    font-weight: 600;
    color: #1976d2;
    font-size: 15px;
}

.param-group-header td {
    border-bottom: 2px solid #1976d2;
}

/* 差异高亮 */
.has-difference {
    background: #fff3e0;
}

.best-value {
    background: #e8f5e9;
    font-weight: 600;
    position: relative;
}

.best-value::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    color: #4caf50;
    font-size: 14px;
}

/* 按钮样式 - 使用项目统一变量 */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--text-white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--primary-alpha-20);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-outline-secondary {
    background: transparent;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
}

.btn-outline-secondary:hover {
    background: var(--secondary-color);
    color: var(--text-white);
    border-color: var(--secondary-color);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 64px;
    color: #ccc;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    color: #666;
    margin-bottom: 10px;
}

.empty-state p {
    color: #999;
    margin-bottom: 20px;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .compare-bar-items {
        justify-content: flex-start;
    }

    .compare-item {
        min-width: 100px;
    }

    .compare-item img {
        width: 60px;
        height: 60px;
    }

    .compare-toolbar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .toolbar-right {
        flex-wrap: wrap;
    }

    .compare-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .compare-table {
        min-width: 800px;
    }

    .product-header th {
        min-width: 150px;
    }

    .product-image {
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .compare-bar-actions {
        flex-direction: column;
    }

    .compare-bar-actions button {
        width: 100%;
    }

    .toolbar-right button {
        flex: 1;
        min-width: 0;
    }
}

/* ========== 产品选择区样式 ========== */
.product-selection-area {
    padding: 30px 20px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.selection-header {
    text-align: center;
    margin-bottom: 30px;
}

/* 快捷筛选区 */
.quick-filters {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.filter-group {
    margin-bottom: 15px;
}

.filter-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 15px;
    display: inline-block;
    min-width: 80px;
}

.filter-buttons {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 16px;
    border: 1px solid var(--border-light);
    background: var(--bg-white);
    color: var(--text-secondary);
    border-radius: 18px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-btn.active {
    background: var(--primary-color);
    color: var(--text-white);
    border-color: var(--primary-color);
}

.popular-products {
    padding-top: 15px;
    border-top: 1px solid var(--border-light);
}

.popular-chips {
    display: inline-flex;
    gap: 12px;
    flex-wrap: wrap;
}

.chip {
    padding: 8px 14px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.chip:hover {
    background: var(--primary-alpha-10);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.selection-header h3 {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
}

.selection-header p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

/* 产品选择器列表 */
.product-selectors {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 30px;
}

.product-selector-item {
    position: relative;
}

.product-selector-item label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    font-size: 15px;
}

.product-selector-item label .optional {
    font-weight: normal;
    color: #999;
    font-size: 13px;
}

/* 自定义搜索选择框 */
.custom-select-wrapper {
    position: relative;
}

.product-search-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
}

.product-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.product-search-input::placeholder {
    color: #aaa;
}

/* 搜索下拉框 */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.search-dropdown.active {
    display: block;
}

.dropdown-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: background 0.2s;
}

.dropdown-item:hover:not(.disabled) {
    background: #f8f9fa;
}

.dropdown-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8f8f8;
}

.dropdown-item-info {
    flex: 1;
}

.dropdown-item-model {
    font-weight: 600;
    color: #333;
    font-size: 15px;
    margin-bottom: 5px;
    font-family: monospace;
}

.dropdown-item-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.series-tag,
.category-tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
    font-weight: 500;
}

.series-tag {
    background: #e3f2fd;
    color: #1976d2;
}

.category-tag {
    background: #f3e5f5;
    color: #7b1fa2;
}

.selected-badge {
    color: #dc3545;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.dropdown-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.dropdown-more {
    padding: 12px 15px;
    text-align: center;
    color: #666;
    font-size: 12px;
    background: #fffbea;
    border-top: 1px solid #f0f0f0;
    font-style: italic;
}

.dropdown-hint {
    padding: 10px 15px;
    background: #e3f2fd;
    color: #1565c0;
    font-size: 12px;
    border-bottom: 1px solid #90caf9;
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.dropdown-hint i {
    font-size: 14px;
}

/* 已选产品预览 */
.selected-product-preview {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--bg-light);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.preview-info {
    flex: 1;
}

.preview-name {
    font-weight: 600;
    color: #333;
    font-size: 15px;
    margin-bottom: 4px;
}

.preview-series {
    font-size: 13px;
    color: #666;
}

.selected-product-preview .btn-remove {
    background: #dc3545;
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.selected-product-preview .btn-remove:hover {
    background: #c82333;
}

/* 操作按钮区 */
.selection-actions {
    text-align: center;
    padding-top: 20px;
}

.selection-actions .btn {
    margin: 0 10px;
    min-width: 150px;
    padding: 14px 35px;
    font-size: 15px;
    font-weight: 600;
}

.table-actions {
    margin-bottom: 15px;
}

/* 产品选择区响应式设计 */
@media (max-width: 992px) {
    .product-selectors {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .dropdown-item-model {
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .product-selection-area {
        padding: 20px 15px;
    }

    .selection-header h3 {
        font-size: 20px;
    }

    .selection-header p {
        font-size: 13px;
    }

    .product-selector-item label {
        font-size: 14px;
    }

    .product-search-input {
        padding: 10px 12px;
        font-size: 13px;
    }

    .search-dropdown {
        max-height: 250px;
    }

    .dropdown-item {
        padding: 10px 12px;
    }

    .selection-actions .btn {
        min-width: 120px;
        padding: 10px 20px;
        font-size: 14px;
        margin: 5px;
    }
}

@media (max-width: 768px) {
    .table-actions {
        flex-direction: column;
        gap: 15px;
        padding: 10px;
    }

    .actions-left,
    .actions-right {
        width: 100%;
    }

    .actions-right {
        flex-wrap: wrap;
        justify-content: center;
    }

    .export-actions {
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .selection-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .selection-actions .btn {
        width: 100%;
        margin: 0;
    }

    .export-actions .btn {
        flex: 1;
        min-width: 100px;
    }
}

/* ================================
   搜索下拉列表样式优化
   ================================ */
.search-result-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: all 0.2s ease;
    background: white;
}

.search-result-item:hover {
    background: linear-gradient(to right, #f8f9fa 0%, #e9ecef 100%);
    padding-left: 20px;
}

.search-result-item:last-child {
    border-bottom: none;
    border-radius: 0 0 6px 6px;
}

.search-result-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #fafafa;
}

.search-result-item.disabled:hover {
    background: #fafafa;
    padding-left: 15px;
}

.result-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.result-info {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 13px;
}

.result-series {
    color: #666;
    padding: 2px 8px;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 12px;
}

.result-spec {
    color: #999;
    font-size: 12px;
}

.no-results {
    padding: 30px 15px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* 已选中标记 */
.search-result-item.selected {
    background: #e8f4fd;
    position: relative;
}

.search-result-item.selected::after {
    content: '✓';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-size: 18px;
    font-weight: bold;
}

/* ================================
   对比表格产品头部样式
   ================================ */
.product-header-cell {
    vertical-align: top;
}

.product-header-cell .product-info {
    text-align: center;
    padding: 10px;
}

.product-header-cell .product-info img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 4px;
    background: #f5f5f5;
}

.product-info{
    width: 100%;
}

.product-header-cell .product-info h4 {
    font-size: 16px;
    font-weight: 600;
    color:var(--bg-white);
    margin: 0 0 5px 0;
    word-break: break-word;
    line-height: 1.3;
}

.product-header-cell .product-info p {
    font-size: 13px;
    color: #666;
    margin: 0;
    padding: 2px 8px;
    background: #f0f0f0;
    border-radius: 12px;
    display: inline-block;
}

.product-header-cell .product-info p:empty {
    display: none;
}

/* ================================
   对比表格操作区域样式
   ================================ */
.table-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.actions-left {
    display: flex;
    align-items: center;
}

.actions-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.filter-actions {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 6px;
    cursor: pointer;
}

.export-actions {
    display: flex;
    gap: 10px;
}

.export-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 14px;
}

.btn-outline-primary {
    color: var(--primary-color);
    background-color: transparent;
    border: 1px solid var(--primary-color);
}

.btn-outline-primary:hover {
    color: white;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* 导出提示样式 */
.export-tip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 40px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 8px;
    z-index: 10000;
    font-size: 16px;
}

/* ================================
   对比表格参数高亮样式
   ================================ */
.compare-table tbody tr.has-difference {
    background-color: #fffbf0;
}

.compare-table tbody tr.has-difference:hover {
    background-color: #fff8e1;
}

.compare-table tbody td.best-value {
    color: #2e7d32;
    font-weight: 600;
    position: relative;
}

.compare-table tbody td.best-value::before {
    content: '★';
    position: absolute;
    left: 5px;
    color: #ffc107;
    font-size: 12px;
}

/* 参数分组标题样式 */
.compare-table tr.param-group-header {
    background: linear-gradient(to right, #f5f5f5, #e8e8e8);
    font-weight: 600;
    color: #333;
}

.compare-table tr.param-group-header td {
    padding: 12px 16px;
    font-size: 15px;
    border-top: 2px solid #ddd;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
