/* ============================================================
 * run-shop-comparison.css
 * 跑商物价对照式双行布局（前台 index.html 与后台 admin 共用）
 *
 * 结构：
 *   .run-shop-list                  容器，垂直堆叠城市卡
 *     .run-shop-city                单个城市卡
 *       .run-shop-city-header       城市名 + 趋势图标 + 计数
 *       .run-shop-grid              CSS Grid，列 = 商品，2 行 = 货商/商人
 *         .run-shop-label-col       sticky 左侧 NPC 标签列
 *         .run-shop-cell            商品格：商品名(买/卖) + 价格 + 绿点
 * ============================================================ */

.run-shop-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px;
}

.run-shop-city {
    background: var(--card-bg);
    border: var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.run-shop-city-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: var(--border);
    background: var(--city-header-bg, var(--intensity-4));
}

.run-shop-city-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--city-header-text, var(--text-primary));
    letter-spacing: 0.02em;
}

.run-shop-city-count {
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--intensity-8);
    padding: 1px 8px;
    border-radius: 999px;
}

.run-shop-trends {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 2px;
    font-size: 13px;
    line-height: 1;
}

.run-shop-trend-up { color: var(--success); font-weight: 700; }
.run-shop-trend-down { color: var(--destructive); font-weight: 700; }
.run-shop-trend-flat { color: var(--text-tertiary); font-weight: 600; }

/* 横向滚动网格：列 = 商品（每城列数不同，用 inline style 设置 grid-template-columns） */
.run-shop-grid {
    display: grid;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.run-shop-grid::-webkit-scrollbar { height: 8px; }
.run-shop-grid::-webkit-scrollbar-thumb {
    background: var(--intensity-12);
    border-radius: 4px;
}
.run-shop-grid::-webkit-scrollbar-track { background: transparent; }

/* 左侧 NPC 标签列：sticky */
.run-shop-label-col {
    position: sticky;
    left: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    background: var(--intensity-4);
    border-right: var(--border);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.run-shop-label-col.is-npc-huoshang { background: color-mix(in srgb, var(--primary) 10%, var(--card-bg)); color: var(--accent); }
.run-shop-label-col.is-npc-shangren { background: color-mix(in srgb, var(--info, #3b82f6) 10%, var(--card-bg)); color: var(--info, #3b82f6); }

.run-shop-label-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    background: var(--intensity-8);
    color: inherit;
    flex-shrink: 0;
}

/* 商品格子 */
.run-shop-cell {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 8px 10px;
    border-right: var(--border);
    border-bottom: var(--border);
    min-height: 56px;
    background: var(--card-bg);
}

.run-shop-cell.is-last-col { border-right: 0; }
.run-shop-cell.is-last-row { border-bottom: 0; }

/* 方向色彩：(买)=玩家卖给NPC=玩家收钱=绿 / (卖)=玩家从NPC买=玩家付钱=橙 */
.run-shop-cell.is-buy .run-shop-cell-price {
    color: var(--success);
}
.run-shop-cell.is-buy .run-shop-cell-dot {
    background: var(--success);
    box-shadow: 0 0 4px color-mix(in srgb, var(--success) 50%, transparent);
}
.run-shop-cell.is-sell .run-shop-cell-price {
    color: var(--warning);
}
.run-shop-cell.is-sell .run-shop-cell-dot {
    background: var(--warning);
    box-shadow: 0 0 4px color-mix(in srgb, var(--warning) 50%, transparent);
}

/* 区域分隔：第一个 (买) 格左侧加一条加粗分隔线 */
.run-shop-cell.is-first-buy {
    box-shadow: inset 2px 0 0 var(--intensity-12);
}
.run-shop-cell.is-first-buy.is-last-col {
    /* 当只有 1 列时不要双 border */
    box-shadow: none;
}

/* 城市 header 内的「卖 X / 买 Y」分项计数 */
.run-shop-city-counts {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
}
.run-shop-city-counts .count-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--intensity-6);
    color: var(--text-secondary);
}
.run-shop-city-counts .count-chip.sell { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent); }
.run-shop-city-counts .count-chip.buy  { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }

.run-shop-cell-name {
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.2;
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.run-shop-cell-name .dir-tag {
    font-size: 10px;
    color: var(--text-tertiary);
    font-weight: 400;
}

.run-shop-cell-price {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    font-weight: 600;
    color: var(--success);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.run-shop-cell-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 4px color-mix(in srgb, var(--success) 50%, transparent);
    flex-shrink: 0;
}

.run-shop-cell-empty {
    color: var(--text-tertiary);
    font-size: 12px;
    text-align: center;
}

.run-shop-cell .cell-delta {
    font-size: 10px;
    margin-left: 2px;
    font-weight: 500;
}
.run-shop-cell .cell-delta.up { color: var(--success); }
.run-shop-cell .cell-delta.down { color: var(--destructive); }

/* 后台专用：可点击的格子 + hover 出现编辑图标 */
.run-shop-city.is-editable .run-shop-cell.has-data {
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}
.run-shop-city.is-editable .run-shop-cell.has-data:hover {
    background: var(--intensity-6);
}
.run-shop-city.is-editable .run-shop-cell.has-data::after {
    content: "✎";
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    opacity: 0;
    transition: opacity 0.15s;
}
.run-shop-city.is-editable .run-shop-cell.has-data:hover::after {
    opacity: 1;
    color: var(--accent);
}

/* 后台：城市 header 的操作按钮 */
.run-shop-city-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.run-shop-city-actions .icon-btn-sm {
    width: 26px;
    height: 26px;
    border: var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}
.run-shop-city-actions .icon-btn-sm:hover {
    background: var(--intensity-6);
    color: var(--text-primary);
}
.run-shop-city-actions .icon-btn-sm.danger:hover { color: var(--destructive); }

/* 响应式：移动端让格子更紧凑 */
@media (max-width: 768px) {
    .run-shop-list { padding: 10px; gap: 10px; }
    .run-shop-city-header { padding: 8px 12px; }
    .run-shop-label-col { padding: 0 10px; font-size: 11px; }
    .run-shop-cell { padding: 6px 8px; min-height: 50px; }
    .run-shop-cell-name { font-size: 11px; }
    .run-shop-cell-price { font-size: 13px; }
}
