/* ============================================================
   IFC 在线预览器样式
   与 sjqy 网站主题色系 (--color-primary: #1a3a5c) 保持一致
   ============================================================ */

/* 预览器外层容器 */
.ifc-viewer-wrapper {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #0f1923;
  position: relative;
}

/* 3D 渲染画布容器 */
#ifc-canvas-container {
  flex: 1;
  position: relative;
  min-width: 0;
  overflow: hidden;
}

#ifc-canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/*
 * The site's generic fullscreen file rule later sets preview wrappers to
 * height:auto. For an IFC flex canvas this creates a percentage-height
 * feedback loop, so the canvas grows on every ResizeObserver callback.
 */
.content-area-fullscreen #pageContent .docfile-preview-wrapper.ifc-preview-wrapper.docfile-preview-fullscreen {
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  flex: 0 0 100vh !important;
}

.content-area-fullscreen .ifc-preview-wrapper > div,
.content-area-fullscreen .ifc-preview-wrapper .ifc-viewer-wrapper,
.content-area-fullscreen .ifc-preview-wrapper #ifc-canvas-container {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
}

/* 右侧面板（模型树 + 属性面板） */
.ifc-side-panel {
  width: 280px;
  min-width: 220px;
  max-width: 360px;
  background: #1a2332;
  border-left: 1px solid #2a3a4e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.2s ease;
}

.ifc-side-panel.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
}

/* 面板标签页 */
.ifc-panel-tabs {
  display: flex;
  background: #141e2b;
  border-bottom: 1px solid #2a3a4e;
  flex-shrink: 0;
}

.ifc-panel-tab {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 500;
  color: #6b8099;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.ifc-panel-tab:hover {
  color: #a0b4c8;
  background: rgba(255,255,255,0.04);
}

.ifc-panel-tab.active {
  color: #c9a227;
  border-bottom: 2px solid #c9a227;
  background: rgba(201,162,39,0.06);
}

/* 面板内容区 */
.ifc-panel-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ifc-panel-section {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.ifc-panel-section.active {
  display: flex;
}

/* 模型树 */
.ifc-tree-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.ifc-tree-scroll::-webkit-scrollbar {
  width: 4px;
}

.ifc-tree-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.ifc-tree-scroll::-webkit-scrollbar-thumb {
  background: #2a3a4e;
  border-radius: 2px;
}

.ifc-tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
  color: #8aa0b4;
  transition: background 0.1s, color 0.1s;
  user-select: none;
  min-height: 24px;
}

.ifc-tree-node:hover {
  background: rgba(255,255,255,0.05);
  color: #c0d0e0;
}

.ifc-tree-node.selected {
  background: rgba(201,162,39,0.12);
  color: #c9a227;
}

.ifc-tree-toggle {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #4a6070;
  transition: transform 0.15s;
}

.ifc-tree-toggle.open {
  transform: rotate(90deg);
}

.ifc-tree-toggle.leaf {
  visibility: hidden;
}

.ifc-tree-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

.ifc-tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
}

.ifc-tree-eye {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #4a6070;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  transition: color 0.15s, background 0.15s;
  opacity: 0;
}

.ifc-tree-node:hover .ifc-tree-eye {
  opacity: 1;
}

.ifc-tree-eye:hover {
  color: #c9a227;
  background: rgba(201,162,39,0.1);
}

.ifc-tree-eye.hidden-item {
  opacity: 1;
  color: #4a6070;
}

.ifc-tree-children {
  display: none;
}

.ifc-tree-children.open {
  display: block;
}

/* 属性面板 */
.ifc-props-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.ifc-props-scroll::-webkit-scrollbar {
  width: 4px;
}

.ifc-props-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.ifc-props-scroll::-webkit-scrollbar-thumb {
  background: #2a3a4e;
  border-radius: 2px;
}

.ifc-props-empty {
  padding: 20px 12px;
  text-align: center;
  color: #4a6070;
  font-size: 12px;
  line-height: 1.6;
}

.ifc-props-group {
  margin-bottom: 12px;
}

.ifc-props-group-title {
  font-size: 10px;
  font-weight: 600;
  color: #c9a227;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 6px;
  border-bottom: 1px solid #2a3a4e;
  margin-bottom: 4px;
}

.ifc-prop-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 3px;
  transition: background 0.1s;
}

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

.ifc-prop-key {
  font-size: 11px;
  color: #6b8099;
  flex-shrink: 0;
  min-width: 80px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-top: 1px;
}

.ifc-prop-val {
  font-size: 11px;
  color: #a0b8cc;
  flex: 1;
  word-break: break-all;
  line-height: 1.5;
}

.ifc-prop-val.highlight {
  color: #c9a227;
  font-weight: 500;
}

/* 工具栏 */
.ifc-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-height: calc(100% - 44px);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 10;
  scrollbar-width: none;
}

.ifc-toolbar::-webkit-scrollbar { display: none; }

.ifc-tool-btn {
  width: 32px;
  height: 32px;
  background: rgba(26,35,50,0.88);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #8aa0b4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  backdrop-filter: blur(4px);
}

.ifc-tool-btn:hover {
  background: rgba(26,58,92,0.9);
  color: #c9a227;
  border-color: rgba(201,162,39,0.4);
}

.ifc-tool-btn.active {
  background: rgba(201,162,39,0.15);
  color: #c9a227;
  border-color: rgba(201,162,39,0.5);
}

.ifc-tool-btn svg {
  width: 15px;
  height: 15px;
}

.ifc-tool-separator {
  width: 24px;
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 2px 0;
}

.ifc-toolbar-collapse svg {
  transition: transform 0.18s ease;
}

.ifc-toolbar.collapsed > :not(#ifc-btn-toolbar-toggle) {
  display: none;
}

.ifc-toolbar.collapsed .ifc-toolbar-collapse svg {
  transform: rotate(180deg);
}

/* 加载遮罩 */
.ifc-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,25,35,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 20;
  color: #8aa0b4;
}

.ifc-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #c9a227;
  border-radius: 50%;
  animation: ifc-spin 0.8s linear infinite;
}

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

.ifc-loading-text {
  font-size: 13px;
  color: #6b8099;
}

.ifc-loading-progress {
  width: 200px;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.ifc-loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1a3a5c, #c9a227);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* 错误提示 */
.ifc-error-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,25,35,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 20;
  color: #8aa0b4;
  padding: 24px;
  text-align: center;
}

.ifc-error-icon {
  color: #dc2626;
  opacity: 0.8;
}

.ifc-error-title {
  font-size: 14px;
  font-weight: 600;
  color: #c0d0e0;
}

.ifc-error-msg {
  font-size: 12px;
  color: #6b8099;
  max-width: 320px;
  line-height: 1.6;
}

/* 底部状态栏 */
.ifc-statusbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: rgba(15,25,35,0.8);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 12px;
  font-size: 10.5px;
  color: #4a6070;
  backdrop-filter: blur(4px);
  z-index: 5;
}

.ifc-statusbar-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ifc-statusbar-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4a6070;
}

.ifc-statusbar-dot.ready {
  background: #16a34a;
}

.ifc-statusbar-dot.loading {
  background: #c9a227;
  animation: ifc-pulse 1s ease-in-out infinite;
}

@keyframes ifc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 剖切面提示 */
.ifc-clip-hint {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,35,50,0.9);
  border: 1px solid rgba(201,162,39,0.3);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 11.5px;
  color: #c9a227;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s;
}

.ifc-clip-hint.visible {
  opacity: 1;
}

.ifc-tool-hint {
  position: absolute;
  bottom: 34px;
  left: 50%;
  max-width: calc(100% - 40px);
  transform: translateX(-50%);
  padding: 7px 12px;
  border: 1px solid rgba(201,162,39,0.35);
  border-radius: 5px;
  background: rgba(20,30,43,0.94);
  color: #e1c45b;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.ifc-tool-hint.visible { opacity: 1; }

:root[data-color-mode="dark"] .ifc-viewer-wrapper,
:root[data-color-mode="dark"] .ifc-side-panel,
:root[data-color-mode="dark"] .ifc-panel-content,
:root[data-color-mode="dark"] .ifc-toolbar,
:root[data-color-mode="dark"] .ifc-statusbar,
:root[data-color-mode="dark"] .ifc-loading-overlay,
:root[data-color-mode="dark"] .ifc-error-overlay {
  background: #11161c !important;
  color: #d8e0ea !important;
  border-color: #3b4552 !important;
}
:root[data-color-mode="dark"] :is(.ifc-panel-tab, .ifc-panel-section, .ifc-prop-row, .ifc-tool-btn) {
  color: #d8e0ea !important;
  border-color: #3b4552 !important;
}
:root[data-color-mode="dark"] :is(.ifc-panel-tab:hover, .ifc-prop-row:hover, .ifc-tool-btn:hover, .ifc-tree-node:hover) {
  background: #2b3440 !important;
}
:root[data-color-mode="dark"] .ifc-tree-node.selected,
:root[data-color-mode="dark"] .ifc-panel-tab.active,
:root[data-color-mode="dark"] .ifc-tool-btn.active {
  background: #343d49 !important;
  color: #f4f7fb !important;
}

@media (max-width: 720px) {
  .ifc-toolbar {
    right: auto;
    overflow-y: auto;
    padding-bottom: 0;
  }

  .ifc-tool-btn { flex: 0 0 auto; }
  .ifc-statusbar-item:last-child { display: none; }
  .ifc-side-panel { width: min(280px, 78vw); }
}

/* 树节点缩进 */
.ifc-tree-level-0 { padding-left: 8px; }
.ifc-tree-level-1 { padding-left: 22px; }
.ifc-tree-level-2 { padding-left: 36px; }
.ifc-tree-level-3 { padding-left: 50px; }
.ifc-tree-level-4 { padding-left: 64px; }
.ifc-tree-level-5 { padding-left: 78px; }

/* 树节点加载状态 */
.ifc-tree-loading {
  padding: 20px 12px;
  text-align: center;
  color: #4a6070;
  font-size: 12px;
}

/* 面板头部 */
.ifc-panel-header {
  padding: 8px 10px 6px;
  border-bottom: 1px solid #2a3a4e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ifc-panel-header-title {
  font-size: 11px;
  font-weight: 600;
  color: #6b8099;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ifc-panel-header-btn {
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: #4a6070;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.ifc-panel-header-btn:hover {
  color: #c9a227;
  background: rgba(201,162,39,0.1);
}

.ifc-panel-header-btn svg {
  width: 12px;
  height: 12px;
}

/* 剖切面控制区 */
.ifc-clip-controls {
  padding: 8px;
  border-top: 1px solid #2a3a4e;
  flex-shrink: 0;
  background: #141e2b;
}

.ifc-clip-title {
  font-size: 10px;
  font-weight: 600;
  color: #6b8099;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.ifc-clip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.ifc-clip-label {
  font-size: 11px;
  color: #6b8099;
  width: 16px;
  flex-shrink: 0;
}

.ifc-clip-slider {
  flex: 1;
  height: 3px;
  appearance: none;
  background: #2a3a4e;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
}

.ifc-clip-slider::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c9a227;
  cursor: pointer;
}

.ifc-clip-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c9a227;
  cursor: pointer;
  border: none;
}

.ifc-clip-toggle {
  width: 22px;
  height: 22px;
  background: none;
  border: 1px solid #2a3a4e;
  border-radius: 4px;
  color: #4a6070;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.ifc-clip-toggle.active {
  background: rgba(201,162,39,0.15);
  border-color: rgba(201,162,39,0.4);
  color: #c9a227;
}

.ifc-clip-toggle svg {
  width: 12px;
  height: 12px;
}

/* 搜索框 */
.ifc-tree-search {
  padding: 6px 8px;
  border-bottom: 1px solid #2a3a4e;
  flex-shrink: 0;
}

.ifc-tree-search input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid #2a3a4e;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11.5px;
  color: #a0b8cc;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.ifc-tree-search input::placeholder {
  color: #4a6070;
}

.ifc-tree-search input:focus {
  border-color: rgba(201,162,39,0.4);
}

/* 框选提示 */
.ifc-box-select-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,35,50,0.9);
  border: 1px solid rgba(201,162,39,0.3);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 11px;
  color: #c9a227;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s;
}

.ifc-box-select-hint.visible {
  opacity: 1;
}
