/* ErisPulse Dashboard – topology (auto-split from dash.css, aligned with js/) */
/* 设计契约：只用 token；无渐变/无玻璃拟态 blur；层级 = 背景三层 + 1px 边框；
   浮层才用 --shadow-hover；胶囊/卡片走圆角阶梯。 */

/* ========== 拓扑图谱页 ========== */

.topo-legend {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--tx-s);
}

.topo-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--bg-s);
    border: 1px solid var(--bd);
    color: var(--tx-s);
    white-space: nowrap;
}

.topo-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}

/* 图例配色与画布取色（topology.js _refreshTopoColors）共用同一组 token */
.topo-legend-dot.module {
    background: var(--accent);
}

.topo-legend-dot.adapter {
    background: var(--ok-c);
}

.topo-legend-dot.bot {
    background: var(--wr-c);
}

.topo-legend-dot.resource {
    background: var(--tx-t);
}

.topo-legend-line {
    width: 18px;
    height: 0;
    display: inline-block;
    flex: 0 0 auto;
    border-top: 2px solid var(--tx-t);
}

.topo-legend-line.dashed {
    border-top-style: dashed;
}

.topo-legend-line.dotted {
    border-top-style: dotted;
}

/* 画布卡：页面纸面上的大卡，背景保持 --bg-p，极淡 1px 边 */
.topo-stage {
    position: relative;
    height: calc(100vh - 250px);
    min-height: 420px;
    background: var(--bg-p);
    border: 1px solid var(--bd);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.topo-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

/* 画布浮层：实底卡片 + 1px 边 + 悬浮柔影（不做玻璃拟态 blur） */
.topo-float {
    position: absolute;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--bg-t);
    border: 1px solid var(--bd);
    box-shadow: var(--shadow-hover);
    font-size: 12px;
    color: var(--tx-s);
    max-width: calc(100% - 28px);
}

.topo-float b {
    color: var(--tx-p);
    font-size: 13px;
    white-space: nowrap;
}

.topo-float label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    white-space: nowrap;
}

.topo-float input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    accent-color: var(--accent);
}

.topo-float-tl {
    top: 14px;
    left: 14px;
}

.topo-float-tr {
    top: 14px;
    right: 14px;
}

.topo-float-bl {
    bottom: 14px;
    left: 14px;
}

.topo-empty-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tx-t);
    font-size: 13px;
    pointer-events: none;
}

.topo-canvas.dragging {
    cursor: grabbing;
}

/* 节点详情面板：标准卡片语义（--bg-t + 1px --bd + radius 16 + 悬浮柔影） */
.topo-detail {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 300px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    background: var(--bg-t);
    border: 1px solid var(--bd);
    border-radius: var(--radius-lg);
    padding: 16px;
    font-size: 12px;
    color: var(--tx-p);
    box-shadow: var(--shadow-hover);
    z-index: 5;
}

.topo-detail h4 {
    margin: 0 0 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    word-break: break-all;
    padding-right: 26px;
}

.topo-detail-actions {
    margin-top: 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ↓ master-dist：权限页复用（permissions.js），保持不动 */

.master-dist {
    margin: 4px 0 4px;
    padding: 12px 16px;
    border: 1px solid var(--bd);
    border-radius: var(--radius-lg);
    background: var(--bg-t);
}

.master-dist-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 12px;
}

.master-dist-row:last-child {
    margin-bottom: 2px;
}

.master-dist-name {
    width: 110px;
    flex-shrink: 0;
    color: var(--tx-s);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.master-dist-bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--bd) 55%, transparent);
    overflow: hidden;
}

.master-dist-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.master-dist-count {
    width: 26px;
    flex-shrink: 0;
    color: var(--tx-t);
    font-weight: 600;
    text-align: right;
}

.topo-detail-kv {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
    word-break: break-all;
}

.topo-detail-k {
    color: var(--tx-t);
    flex-shrink: 0;
}

.topo-detail-v {
    color: var(--tx-p);
}

.topo-detail-list {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin: 6px 0;
}

.topo-detail-close {
    position: absolute;
    top: 8px;
    right: 8px;
}

/* ========== 拓扑图增强 ========== */

.topo-stats {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.topo-stats .chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.topo-stats .chip svg {
    width: 11px;
    height: 11px;
}

/* 悬停提示：小件层级（radius-sm）+ 实底 + 柔影 */
.topo-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 6;
    display: none;
    max-width: 260px;
    background: var(--bg-t);
    border: 1px solid var(--bd);
    border-radius: var(--radius-sm);
    padding: 5px 9px;
    font-size: 12px;
    color: var(--tx-p);
    box-shadow: var(--shadow-hover);
    word-break: break-all;
}

.topo-tooltip .tt-type {
    margin-left: 6px;
    font-size: 11px;
    color: var(--tx-t);
}

/* ========== 拓扑画布触摸手势 ========== */

.topo-canvas {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ========== 拓扑页移动端适配 ==========
   注意：必须位于上方桌面规则之后，媒体查询才能覆盖
   .topo-float-tr 的 top:14px，否则浮层会被 top+bottom 双向拉伸 */

@media (max-width: 720px) {
    .topo-stage {
        height: calc(100vh - 285px);
        min-height: 340px;
    }

    .topo-float-tl {
        left: 10px;
        right: 10px;
        top: 10px;
        max-width: none;
        flex-wrap: wrap;
    }

    .topo-float-tr {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 10px;
        max-width: none;
        justify-content: center;
        flex-wrap: wrap;
        padding: 6px 12px;
        gap: 6px 12px;
    }

    .topo-float-bl {
        display: none;
    }

    .topo-detail {
        width: calc(100% - 24px);
    }
}

/* 减少动效：详情/提示面板与图例不做过渡装饰（画布动画由 JS 侧门控） */
@media (prefers-reduced-motion: reduce) {
    .topo-detail,
    .topo-tooltip,
    .topo-float {
        transition: none;
    }
}
