/* ============================================================
   CBG 独立页面共用样式
   由 cbg_list.html / cbg_compare.html 共同引用，
   统一背景、顶部导航、卡片、对比徽章/表格、移动端表现。
   主题色沿用主搜索页品牌色 #ff3a36。
   ============================================================ */

/* ---------- 基础 ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background-color: #f5f5f5;
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Heiti SC", miui, helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.7;
}

a:hover {
    text-decoration: none;
}

/* 容器靠边渲染，卡片铺满（与旧内联样式一致） */
.uk-container,
.uk-container-large {
    padding-left: 0;
    padding-right: 0;
}

/* 卡片统一描边，替代 uikit 默认投影 */
.uk-card {
    border: 1px solid #eef2f6;
}

/* ---------- 对比页静态页头（复用 page-head 视觉，不吸顶） ---------- */
/* 用双选择器提升特异性，压过下方 .page-head 的 position: sticky */
.page-head.page-head-static {
    position: static;
}

.head-btn {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #444;
    font-size: 13px;
    transition: all 0.2s ease;
}

.head-btn:hover,
.head-btn:focus {
    border-color: #ffd9d6;
    color: #ff3a36;
    background: #fff1f0;
}

/* ---------- 列表页卡片 ---------- */

.color-primary {
    color: #1e1e1e;
}

/* 列表页内容统一自适应左右出边距：手机 12px / ≥640px 40px / ≥1200px 70px。
   同时用于 page-head、filter-bar（排序栏）与 #item-list（卡片），
   保证排序按钮左缘与卡片左缘对齐。 */
:root {
    --cbg-gutter: 12px;
}

@media (min-width: 640px) {
    :root {
        --cbg-gutter: 40px;
    }
}

@media (min-width: 1200px) {
    :root {
        --cbg-gutter: 70px;
    }
}

#item-list.uk-grid {
    margin-left: 0;
}

/* 卡片（uk-child-width-1-1 的子元素）改为对称的自适应内边距：
   覆盖 uk-grid-large 子元素仅左侧 40px/70px 的不对称内边距，
   统一为 --cbg-gutter（12/40/70px），与排序栏左缘对齐。
   纵向间距：覆盖 uk-grid-large 的 .uk-grid-margin（40px/70px）
   与卡片自带 .uk-margin-small（10px），压到 2px。 */
#item-list.uk-grid > * {
    padding-left: var(--cbg-gutter);
    padding-right: var(--cbg-gutter);
    margin-top: 2px !important;
    margin-bottom: 2px !important;
}

/* 卡片统一上下 2px：覆盖 uk-grid-large 的 .uk-grid-margin（40px/70px）
   与卡片自带 .uk-margin-small（10px），压到 2px。 */
#item-list .uk-card {
    margin-top: 2px !important;
    margin-bottom: 2px !important;
}

.custom-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sect-primary {
    color: #1e1e1e;
    font-size: 130%;
    font-weight: 600;
}

.price-highlight {
    color: #ff3a36;
    font-size: 140%;
    font-weight: 700;
    line-height: 1.2;
}

.extra-info {
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 12px;
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 0.85rem;
}

.extra-item {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.extra-label {
    font-weight: 500;
    color: #64748b;
}

.extra-number {
    font-weight: 600;
    color: #0f172a;
}

/* 右侧悬浮工具按钮（反馈/对比等） */
.float-tools {
    display: flex;
    flex-direction: column;
    gap: 10px;
    right: 16px;
    bottom: 16px;
    z-index: 9999;
}

.tool-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
    color: #444;
}

.tool-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
    color: #000;
}

.tool-btn:active {
    transform: translateY(-1px) scale(0.96);
}

/* ---------- 对比页：状态徽章 / 摘要 / 表格 ---------- */

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    color: #fff;
    min-width: 40px;
    text-align: center;
}

.status-same {
    background-color: #94a3b8;
}

.status-modified {
    background-color: #f59e0b;
}

.status-added {
    background-color: #10b981;
}

.status-deleted {
    background-color: #ef4444;
}

.field-row td {
    vertical-align: middle;
    word-break: break-all;
}

.field-name {
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}

.val-diff {
    color: #dc2626;
    background: #fef2f2;
}

.diff-highlight {
    background-color: #fef3c7;
}

.summary-card {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.summary-item {
    text-align: center;
    min-width: 80px;
    padding: 10px 16px;
    border-radius: 12px;
    background: #f8fafc;
}

.summary-item .num {
    font-size: 24px;
    font-weight: 700;
    display: block;
}

.summary-item .label {
    font-size: 12px;
    color: #64748b;
}

.summary-total .num {
    color: #3b82f6;
}

.summary-same .num {
    color: #94a3b8;
}

.summary-modified .num {
    color: #f59e0b;
}

.summary-added .num {
    color: #10b981;
}

.summary-deleted .num {
    color: #ef4444;
}

.presence-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    color: #fff;
    min-width: 28px;
    text-align: center;
}

.tag-yes {
    background-color: #10b981;
}

.tag-no {
    background-color: #ef4444;
}

.elem-text {
    word-break: break-all;
}

.id-copy {
    cursor: pointer;
    color: #2563eb;
    font-size: 12px;
}

/*
 * 吸顶表头：桌面端页面滚动时表头固定在最顶部。
 * 注意：桌面端不要把表格包在 overflow:auto 容器里，否则该容器会成为
 * 滚动容器、吸顶失效；移动端才为表格容器开启横向滚动（见下方 media query）。
 */
:root {
    --sticky-top: 0;
}

.sticky-thead {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-scroll {
    width: 100%;
}

.sticky-thead thead th {
    position: sticky;
    top: var(--sticky-top, 80px);
    z-index: 5;
    background-color: #fff;
    box-shadow: inset 0 -1px 0 0 #e5e7eb;
}

/* ---------- 对比页：队列添加输入行 ---------- */

.cmp-hint {
    color: #64748b;
}

/* ---------- 列表页双行头（参考官方列表页） ---------- */

/* 首行：返回 | 标题 | 首页，随滚动隐藏 */
.page-head {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--cbg-gutter);
    background: #fff;
    border-bottom: 1px solid #eef2f6;
    transition: transform 0.25s ease;
}

body.page-scrolled .page-head {
    transform: translateY(-100%);
}

.page-title {
    font-size: 17px;
    font-weight: 600;
    color: #1e1e1e;
}

.head-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: #444;
}

.head-icon:active {
    opacity: 0.6;
}

/* 次行：排序 + 去对比，吸顶成为新的顶部 */
.filter-bar {
    position: sticky;
    top: 44px;
    z-index: 999;
    background: #fff;
    border-bottom: 1px solid #eef2f6;
    padding-left: var(--cbg-gutter);
    padding-right: var(--cbg-gutter);
    transition: top 0.25s ease;
}

body.page-scrolled .filter-bar {
    top: 0;
}

.filter-bar .uk-navbar-nav {
    white-space: nowrap;
}

.cmp-count-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    margin-left: 4px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ff3a36;
    color: #fff;
    font-size: 11px;
    text-align: center;
    vertical-align: middle;
}

/* 「去对比」按钮：浅底胶囊替代 uikit 默认实心蓝，呼应品牌色 */
#goto-compare {
    border-radius: 999px;
    background: #fff1f0;
    border: 1px solid #ffd9d6;
    color: #ff3a36;
    line-height: 26px;
    padding: 0 14px;
    font-weight: 500;
    box-shadow: none;
    transition: all 0.2s ease;
}

#goto-compare:hover,
#goto-compare:focus {
    background: #ffe5e2;
    border-color: #ff9a94;
    color: #e82e2a;
    box-shadow: none;
}

#goto-compare:active {
    background: #ffdbd7;
    transform: scale(0.97);
}

/* 卡片足部订单 ID 展示 */
.card-id {
    font-size: 12px;
}

/* 卡片足部「加入对比」切换按钮 */
.cmp-toggle {
    transition: all 0.2s ease;
}

.cmp-toggle.is-on {
    background: #ff3a36 !important;
    border-color: #ff3a36 !important;
    color: #fff !important;
}

/* ---------- 卡片评论：角标 / 展开区 / 新增表单 ---------- */

/* 卡片足部 ID 超出时截断隐藏（flex 收缩需 min-width: 0） */
.card-id {
    flex: 1 1 auto;
    min-width: 0;
}

/* 评论切换：仅图标 + 数字，内联在「加入对比」左侧 */
.card-comments-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.card-comments-toggle:hover {
    color: #ff3a36;
    background: #fff1f0;
}

/* 评论数量胶囊角标（呼应 .cmp-count-badge） */
.card-comments-count {
    display: inline-block;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #ff3a36;
    color: #fff;
    font-size: 11px;
    text-align: center;
    vertical-align: middle;
}

.card-comments {
    margin-top: 8px;
    border-top: 1px solid #eef2f6;
    padding-top: 8px;
}

.card-comments-body {
    margin-top: 0;
}

.card-comments-list {
    max-height: 260px;
    overflow-y: auto;
}

.card-comments-empty {
    color: #94a3b8;
    font-size: 13px;
    margin: 6px 0;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 8px;
}

.card-comment-item {
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #f8fafc;
    border-radius: 10px;
}

.card-comment-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

.card-comment-author {
    font-weight: 600;
    color: #1e293b;
    font-size: 13px;
}

.card-comment-time {
    color: #94a3b8;
    font-size: 12px;
}

.card-comment-content {
    color: #334155;
    font-size: 13px;
    word-break: break-word;
    white-space: pre-wrap;
}

.card-comments-form {
    margin-top: 8px;
}

.card-comments-form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.card-comments-name {
    flex: 0 0 120px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 13px;
}

.card-comments-input {
    flex: 1 1 auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 13px;
    resize: vertical;
}

.card-comments-name:focus,
.card-comments-input:focus {
    border-color: #ff3a36;
    outline: none;
}

.card-comments-submit {
    flex-shrink: 0;
    border-radius: 999px;
    background: #ff3a36;
    color: #fff;
    align-self: flex-end;
    border: none;
}

.card-comments-submit:hover {
    background: #e82e2a;
    color: #fff;
}

/* ---------- 对比页：对比队列（行式条目，备注 + 选中/编辑/删除） ---------- */

/* 覆盖 uikit .uk-flex-wrap，队列改为纵向单列 */
#queue-list {
    display: block;
}

.cmp-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cmp-row:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.cmp-row.selected {
    border-color: #ff3a36;
    background: #fff1f0;
}

/* 选中圆圈（左侧） */
.cmp-select {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    color: #fff;
}

.cmp-row.selected .cmp-select {
    background: #ff3a36;
    border-color: #ff3a36;
}

/* 备注 + 小号 ID */
.cmp-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cmp-remark {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    word-break: break-all;
}

.cmp-remark-empty {
    color: #94a3b8;
    font-weight: 400;
}

.cmp-id-sub {
    font-size: 12px;
    color: #94a3b8;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 操作按钮（编辑 / 删除） */
.cmp-actions {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
}

.cmp-act {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s ease;
}

.cmp-act span {
    display: inline-flex;
    line-height: 1;
}

.cmp-act:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.cmp-edit:hover {
    background: #eff6ff;
    color: #2563eb;
}

.cmp-del:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* 行内编辑态 */
.cmp-row.editing {
    cursor: default;
    background: #fff;
}

.cmp-edit-bar {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cmp-edit-input {
    width: 100%;
}

.cmp-edit-input:focus {
    border-color: #ff3a36;
}

/* ---------- 数组卡片：关键字过滤 + 多列有无排序 ---------- */

.arr-filter {
    min-width: 160px;
}

/* 卡片折叠：标题栏可点击，折叠时隐藏体 */
.arr-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    flex-wrap: wrap;
    cursor: pointer;
    user-select: none;
}

.arr-chevron {
    margin-left: 6px;
    font-size: 12px;
    color: #94a3b8;
    transition: all 0.2s ease;
}

.arr-card:not(.arr-collapsed) .arr-chevron {
    color: #ff3a36;
}

.arr-card.arr-collapsed .arr-body {
    display: none;
}

.sort-th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sort-th .sort-ind {
    margin-left: 4px;
    font-size: 11px;
    color: #94a3b8;
}

.sort-th.sort-active .sort-ind {
    color: #ff3a36;
    font-weight: 700;
}

.sort-rank {
    display: inline-block;
    min-width: 15px;
    height: 15px;
    line-height: 15px;
    margin-left: 4px;
    padding: 0 4px;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 10px;
    text-align: center;
    vertical-align: middle;
}

.sort-th.sort-active .sort-rank {
    background: #ff3a36;
    color: #fff;
}

/* ---------- 移动端适配 ---------- */

@media screen and (max-width: 640px) {
    .uk-card-body {
        padding: 8px 12px;
    }

    .extra-info {
        gap: 8px 12px;
        font-size: 0.8rem;
    }

    /* 摘要数字稍小 */
    .summary-item .num {
        font-size: 20px;
    }

    /* 对比表格窄屏允许横向滚动；同时关闭吸顶避免冲突 */
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-scroll .sticky-thead thead th {
        position: static;
        box-shadow: none;
    }

    /* 队列条目：窄屏压缩间距 */
    .cmp-row {
        gap: 8px;
        padding: 8px 10px;
    }
}