/* viz.css —— 拖拽搭建编辑器：复用物联网控制台 :root 变量与字号，只补编辑器特有布局。 */

#vizView { display: none; }
#vizView.open { display: block; }
#mainGrid.hidden, #mainHeader.hidden { display: none; }

/* 三栏：左组件库 220 / 中画布自适应 / 右属性 260 */
.viz-editor { display: flex; gap: 12px; align-items: stretch; height: calc(100vh - 110px); min-height: 560px; }

/* ---- 左：组件库 ---- */
.viz-lib { width: 220px; flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-soft); display: flex; flex-direction: column; overflow: hidden; }
.viz-search { margin: 10px; padding: 6px 10px; font-size: 14px; }
.viz-lib-list { overflow: auto; padding: 0 10px 12px; flex: 1; }
.viz-lib-group { font-size: 12px; color: var(--sub); margin: 12px 0 6px; padding-left: 2px; }
.viz-lib-item { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 7px 10px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: grab; user-select: none; }
.viz-lib-item:hover { border-color: var(--acc); background: var(--acc2); }
.viz-lib-item:active { cursor: grabbing; }
.viz-lib-item .ic { width: 18px; text-align: center; }
.viz-lib-item.soon { opacity: .45; cursor: not-allowed; }
.viz-lib-item.soon::after { content: "即将上线"; margin-left: auto; font-size: 11px; color: var(--sub); }

/* ---- 中：自由画布（绝对定位，无网格吸附） ---- */
.viz-stage-wrap { flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-soft); overflow: auto; }
.viz-stage { position: relative; width: 2000px; height: 1400px; background-color: #fff; }
.viz-stage-empty { position: absolute; top: 60px; left: 60px; right: 60px; bottom: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--sub); font-size: 18px; text-align: center; border: 2px dashed var(--line); border-radius: 12px; pointer-events: none; }
.viz-stage-empty.hide { display: none; }

/* 画布上的组件（绝对定位，想放哪放哪，拖右下角缩放） */
.vc { position: absolute; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-soft); overflow: hidden; }
.vc.sel { border: 2px solid var(--acc); box-shadow: 0 0 0 3px rgba(79,115,247,.15); }
.vc-head { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--txt); padding: 6px 10px; border-bottom: 1px solid var(--line); background: #fbfcff; cursor: move; }
.vc-head .vc-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-head .vc-del { color: var(--sub); cursor: pointer; padding: 0 4px; }
.vc-head .vc-del:hover { color: var(--bad); }
.vc-body { padding: 10px 12px; height: calc(100% - 32px); overflow: auto; }
.vc-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; }
.vc-resize::after { content: ""; position: absolute; right: 3px; bottom: 3px; width: 8px; height: 8px; border-right: 2px solid var(--acc); border-bottom: 2px solid var(--acc); opacity: .5; }

/* 数值类 */
.vc-val { font-size: 26px; color: var(--acc); font-weight: 700; line-height: 1.2; }
.vc-val .u { font-size: 13px; color: var(--sub); font-weight: normal; margin-left: 3px; }
.vc-sub { font-size: 12px; color: var(--sub); margin-top: 4px; }
.vc-gauge { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.vc-progress-bar { height: 18px; background: var(--acc2); border-radius: 9px; overflow: hidden; margin-top: 8px; }
.vc-progress-bar > i { display: block; height: 100%; background: var(--acc); border-radius: 9px; transition: width .4s; }

/* 交互类 */
.vc-ctrl button { font-size: 14px; padding: 6px 14px; margin: 3px; }
.vc-ctrl input[type=text], .vc-ctrl input[type=number] { font-size: 14px; padding: 5px 8px; }
.vc-slider { display: flex; align-items: center; gap: 8px; }
.vc-slider input[type=range] { flex: 1; min-width: 60px; accent-color: var(--acc); padding: 0; border: none; }
.vc-joystick { position: relative; width: 140px; height: 140px; border-radius: 50%; background: var(--acc2); margin: 0 auto; touch-action: none; }
.vc-joystick .knob { position: absolute; width: 34px; height: 34px; border-radius: 50%; background: var(--acc); left: 53px; top: 53px; }
.vc-palette { width: 100%; height: 60px; padding: 0; border: none; cursor: pointer; }

/* 图表容器 */
.vc-chart { width: 100%; height: 100%; }

/* ---- 右：属性面板 ---- */
.viz-props { width: 260px; flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-soft); padding: 12px; overflow: auto; }
.viz-props-empty { color: var(--sub); font-size: 14px; text-align: center; padding: 40px 10px; line-height: 1.8; }
.vp-row { margin-bottom: 10px; }
.vp-row > label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 3px; }
.vp-row input, .vp-row select { width: 100%; font-size: 14px; padding: 5px 8px; }
.vp-row inline { display: flex; gap: 6px; }
.vp-help { background: #eef7f0; border-left: 3px solid var(--ok); border-radius: 0 8px 8px 0; padding: 8px 10px; margin-top: 12px; font-size: 12px; color: #37624a; line-height: 1.7; word-break: break-all; }
.vp-help b { color: #1e7a45; }
.vp-del { width: 100%; margin-top: 10px; }

@media (max-width: 1100px) {
  .viz-editor { flex-direction: column; height: auto; }
  .viz-lib, .viz-props { width: 100%; max-height: 260px; }
  .viz-stage-wrap { height: 520px; }
}
