/* style.css — 3D 查看器界面（深色主题） */
:root {
  --bg: #11161f;
  --panel: #1a212d;
  --panel-2: #212a38;
  --line: #2c3646;
  --text: #dbe4f0;
  --text-dim: #8595ab;
  --accent: #4ecca3;
  --accent-dim: rgba(78, 204, 163, 0.16);
  --err: #e5695e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- 顶栏 */

#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.brand-mark {
  width: 12px;
  height: 12px;
  background: var(--accent);
  transform: rotate(45deg);
  border-radius: 2px;
  display: inline-block;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.btn:hover { background: #2a3547; border-color: #3a4a63; }

.btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #0c2a1f;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover { background: #5fdcb2; }

.btn-sm { padding: 4px 9px; font-size: 12px; }

/* 下拉菜单 */
.menu-wrap { position: relative; }

.menu-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 50;
  max-height: 60vh;
  overflow-y: auto;
}

.menu-list.open { display: flex; }

.menu-list button {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}

.menu-list button:hover { background: var(--accent-dim); color: var(--accent); }

/* ---------------------------------------------------------------- 舞台 */

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

#stage canvas {
  display: block;
}

#stage.dragging::after {
  content: '释放以打开模型';
  position: absolute;
  inset: 10px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent);
  background: rgba(78, 204, 163, 0.07);
  z-index: 10;
  pointer-events: none;
}

/* 拖放区（空状态） */
#dropzone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.dz-inner {
  text-align: center;
  background: rgba(26, 33, 45, 0.82);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 44px 56px;
  backdrop-filter: blur(4px);
}

.dz-icon { color: var(--accent); margin-bottom: 12px; line-height: 0; }

.dz-title { font-size: 20px; font-weight: 600; margin-bottom: 14px; }

.dz-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 420px;
  margin-bottom: 20px;
}

.fmt-chip {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 10px;
}

.dz-note {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* 加载指示 */
#loading {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(17, 22, 31, 0.72);
  z-index: 30;
  color: var(--text);
  font-size: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 底部工具栏 */

#bottombar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(26, 33, 45, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  z-index: 15;
  backdrop-filter: blur(6px);
  max-width: calc(100% - 24px);
  flex-wrap: wrap;
  justify-content: center;
}

.seg-group {
  display: flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.seg-group button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 6px 12px;
  cursor: pointer;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.seg-group button:last-child { border-right: none; }

.seg-group button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.seg-group button.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ---------------------------------------------------------------- 面板 */

#section-panel {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 12px;
  background: rgba(26, 33, 45, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  z-index: 15;
  backdrop-filter: blur(6px);
}

.sp-label { font-size: 12.5px; color: var(--text-dim); }

#section-slider {
  width: 180px;
  accent-color: var(--accent);
}

#measure-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  background: rgba(78, 204, 163, 0.14);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12.5px;
  border-radius: 8px;
  padding: 6px 14px;
  z-index: 15;
}

#anim-panel {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(26, 33, 45, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  z-index: 15;
  backdrop-filter: blur(6px);
}

#anim-panel select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12.5px;
  padding: 4px 6px;
  max-width: 140px;
}

#anim-time {
  width: 120px;
  accent-color: var(--accent);
}

/* 状态栏 */
#status {
  position: absolute;
  left: 14px;
  top: 12px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(26, 33, 45, 0.85);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 11px;
  z-index: 14;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toast */
#toast {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  border-radius: 9px;
  padding: 9px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 40;
  max-width: 80%;
  text-align: center;
}

#toast.show { opacity: 1; }

#toast.error { border-color: var(--err); color: var(--err); }

/* ---------------------------------------------------------------- IFC 楼层/构件显隐 */

#btn-ifc[hidden] { display: none; }

#ifc-panel {
  position: absolute;
  pointer-events: auto;
  top: 64px;
  right: 14px;
  width: 252px;
  max-height: calc(100% - 150px);
  display: none;
  flex-direction: column;
  background: rgba(26, 33, 45, 0.96);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  z-index: 16;
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

#ifc-panel .ifc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.ifc-title { font-size: 13px; font-weight: 600; }

.ifc-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 8px;
}

.ifc-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.ifc-actions { display: flex; gap: 8px; }

.ifc-actions button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 0;
  cursor: pointer;
}

.ifc-actions button:hover { color: var(--accent); }

.ifc-list {
  overflow: auto;
  max-height: 32vh;
  padding-right: 2px;
}

.ifc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 2px;
  border-radius: 5px;
  font-size: 12.5px;
  cursor: pointer;
}

.ifc-row:hover { background: rgba(255, 255, 255, 0.04); }

.ifc-row input { accent-color: var(--accent); flex: 0 0 auto; }

.ifc-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ifc-meta {
  color: var(--text-dim);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ifc-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.ifc-foot {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- 点击构件信息 */

#element-panel {
  position: absolute;
  left: 14px;
  bottom: 74px;
  width: 286px;
  max-height: 48vh;
  display: none;
  flex-direction: column;
  background: rgba(26, 33, 45, 0.96);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  z-index: 16;
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.el-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.el-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.el-sub {
  margin: 4px 0 6px;
  font-size: 11.5px;
  color: var(--text-dim);
  word-break: break-all;
}

.el-props {
  overflow: auto;
  max-height: 40vh;
}

.el-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
  font-size: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
}

.el-row:first-child { border-top: none; }

.el-key {
  flex: 0 0 76px;
  color: var(--text-dim);
}

.el-val {
  flex: 1;
  word-break: break-all;
}
