/**
 * MGILT 在线设计器 - 新 UI 样式
 * 基于新设计稿重构：顶部品牌导航 + 操作按钮栏 + 左侧流程面板 + 中央画布 + 右侧细节编辑面板
 */

/* ============================================
   1. 设计器整体布局
   ============================================ */

/* 编辑器页面最外层容器 - 去掉默认的 padding-top，因为我们自己做 header */
.designer-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--gray-100);
}

/* ============================================
   2. 顶部主导航 Header (84px)
   ============================================ */

.designer-header {
  height: 84px;
  background: #F7F7F4; /* 浅灰白背景 */
  border-bottom: 1px solid #E0E0DC; /* 细分割线 */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  flex-shrink: 0;
  z-index: 100;
}

/* Header 左侧：logo + 文字导航 */
.designer-header-left {
  display: flex;
  align-items: center;
  gap: 40px;
}

.designer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
}

.designer-logo-dot {
  width: 8px;
  height: 8px;
  background: #7A9E7E; /* MGILT 品牌绿 */
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.designer-logo-text {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 3px;
  color: #0a0a0a;
}

.designer-nav-links {
  display: flex;
  align-items: center;
  gap: 0;
}

.designer-nav-links a {
  font-size: 14px;
  font-weight: 400;
  color: #555555;
  text-decoration: none;
  padding: 8px 16px;
  position: relative;
  transition: color 0.3s;
  white-space: nowrap;
}

.designer-nav-links a:hover {
  color: #0a0a0a;
}

.designer-nav-links a.active {
  color: #0a0a0a;
  font-weight: 500;
}

/* 导航链接之间用 · 分隔 */
.designer-nav-links a + a::before {
  content: '·';
  position: absolute;
  left: 0;
  color: #D0D0CC;
  pointer-events: none;
}

.designer-nav-links a {
  padding-left: 24px;
}

/* Header 右侧：辅助链接 */
.designer-header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.designer-header-right a,
.designer-header-right button {
  font-size: 13px;
  color: #555555;
  text-decoration: none;
  transition: color 0.3s;
  cursor: pointer;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.designer-header-right a:hover,
.designer-header-right button:hover {
  color: #0a0a0a;
}

/* ============================================
   3. 顶部操作栏 Toolbar (68px)
   ============================================ */

.designer-toolbar {
  height: 68px;
  background: #FFFFFF;
  border-bottom: 1px solid #E0E0DC;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  gap: 12px;
  flex-shrink: 0;
}

/* Toolbar 左侧操作按钮组 */
.designer-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 通用工具按钮样式 */
.designer-btn {
  height: 34px;
  width: 88px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 400;
  color: #333333;
  background: #FFFFFF;
  border: 1px solid #D7D7D2;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  gap: 6px;
}

.designer-btn:hover {
  border-color: #7A9E7E;
  color: #7A9E7E;
}

.designer-btn:active {
  background: #F5F5F3;
}

.designer-btn.active {
  background: #7A9E7E;
  color: #FFFFFF;
  border-color: #7A9E7E;
}

/* 绿色主按钮 */
.designer-btn-primary {
  background: #7A9E7E;
  color: #FFFFFF;
  border-color: #7A9E7E;
}

.designer-btn-primary:hover {
  background: #6B8B6B;
  border-color: #6B8B6B;
  color: #FFFFFF;
}

/* 黄色按钮 */
.designer-btn-yellow {
  background: #FFE900;
  color: #0a0a0a;
  border-color: #FFE900;
}

.designer-btn-yellow:hover {
  background: #F0DC00;
  border-color: #F0DC00;
  color: #0a0a0a;
}

/* 宽度自适应按钮 */
.designer-btn-auto {
  width: auto;
  padding: 0 20px;
}

/* ============================================
   4. 主工作区 Main Workspace (三栏)
   ============================================ */

.designer-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* 左侧流程面板 (250px) */
.designer-left-panel {
  width: 250px;
  flex-shrink: 0;
  background: #FFFFFF;
  border-right: 1px solid #E0E0DC;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative; /* 让子元素的绝对定位以此为基准 */
}

/* 中央画布区 */
.designer-canvas-area {
  flex: 1;
  display: flex;
  background: #F2F1EC; /* 浅米灰色画布背景 */
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

/* 右侧细节编辑面板 (255px) */
.designer-right-panel {
  width: 255px;
  flex-shrink: 0;
  background: #FFFFFF;
  border-left: 1px solid #E0E0DC;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ============================================
   5. 左侧流程面板 - 01/02/03 结构
   ============================================ */

.designer-panel-section {
  border-bottom: 1px solid #E8E8E5;
}

.designer-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 20px 16px;
  cursor: pointer;
  user-select: none;
}

.designer-panel-header:hover {
  background: #F9F9F7;
}

.designer-section-number {
  font-size: 13px;
  font-weight: 700;
  color: #7A9E7E;
  font-family: var(--font-display);
}

.designer-section-title {
  font-size: 15px;
  font-weight: 500;
  color: #222222;
  font-family: var(--font-display);
}

.designer-section-arrow {
  margin-left: auto;
  font-size: 11px;
  color: #999999;
  transition: transform 0.2s;
}

.designer-panel-header.collapsed .designer-section-arrow {
  transform: rotate(180deg);
}

.designer-panel-content {
  padding: 0 20px 20px;
}

.designer-panel-content.collapsed {
  display: none;
}

/* 面板内的表单元素 */
.designer-form-group {
  margin-bottom: 12px;
}

.designer-form-label {
  display: block;
  font-size: 12px;
  color: #777777;
  margin-bottom: 6px;
}

.designer-input,
.designer-select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  color: #222222;
  background: #FFFFFF;
  border: 1px solid #D7D7D2;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.designer-input:focus,
.designer-select:focus {
  border-color: #7A9E7E;
}

.designer-input::placeholder {
  color: #AAAAAA;
}

/* 下拉选择框带箭头 */
.designer-select-wrap {
  position: relative;
}

.designer-select-wrap::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #999999;
  pointer-events: none;
}

.designer-select {
  padding-right: 32px;
  cursor: pointer;
}

/* 场景选择下拉 - 带预览气泡 */
.designer-scene-select-wrap {
  position: relative;
}

.designer-scene-select-wrap .designer-select {
  width: 100%;
}

.designer-scene-preview {
  position: fixed;
  z-index: 9999;
  width: 300px;
  height: 200px;
  background: #FFFFFF;
  border: 1px solid #E0E0DC;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  overflow: hidden;
  pointer-events: none;
}

.designer-scene-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.designer-scene-preview .preview-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: #FFFFFF;
  font-size: 12px;
}

/* 两个小输入框并排 */
.designer-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.designer-input-row .designer-input {
  flex: 1;
  text-align: center;
}

.designer-input-suffix {
  font-size: 12px;
  color: #777777;
  flex-shrink: 0;
}

/* 撑满宽度的按钮 */
.designer-btn-full {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

/* 设计统计表格 */
.designer-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.designer-stats-table tr {
  border-bottom: 1px solid #F0F0EC;
}

.designer-stats-table td {
  padding: 8px 0;
  line-height: 1.4;
}

.designer-stats-table td:first-child {
  color: #777777;
}

.designer-stats-table td:last-child {
  color: #222222;
  text-align: right;
  font-weight: 500;
}

/* 设计统计区块浅绿色底色 */
.designer-stats-section {
  background: #e8f0e9;
  border-radius: 8px;
  padding: 16px !important;
  margin: 0 20px 8px;
}

.designer-stats-calc-btn {
  margin-top: 16px;
}

.designer-stats-section .designer-stats-table td:first-child {
  color: #5a7a5e;
}

/* 模块明细展开列表 */
.module-detail-list {
  padding: 8px 0 4px;
}

.mod-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
}

.mod-detail-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mod-detail-row span {
  color: #333;
}

.mod-detail-row strong {
  margin-left: auto;
  color: #222;
  font-weight: 500;
}

/* ============================================
   6. 中央画布区
   ============================================ */

.designer-canvas-wrap {
  position: absolute;
  inset: 0;
}

.designer-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 画布提示文字 */
.designer-canvas-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #999999;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 16px;
  border-radius: 20px;
  pointer-events: none;
}

/* ============================================
   7. 右侧细节编辑面板 - 04 结构
   ============================================ */

/* 模块面板 / 场景元素 可折叠项 */
.designer-collapse-item {
  border: 1px solid #E8E8E5;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.designer-collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #FFFFFF;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 13px;
  color: #222222;
}

.designer-collapse-header:hover {
  background: #F9F9F7;
}

.designer-collapse-header .designer-section-arrow {
  margin-left: 8px;
}

.designer-collapse-content {
  border-top: 1px solid #E8E8E5;
  background: #FAFAF8;
}

.designer-collapse-content.collapsed {
  display: none;
}

/* 折叠项内的行 */
.designer-collapse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 12px;
  color: #555555;
  border-bottom: 1px solid #F0F0EC;
  cursor: pointer;
  transition: background 0.2s;
}

.designer-collapse-row:last-child {
  border-bottom: none;
}

.designer-collapse-row:hover {
  background: #F5F5F3;
}

.designer-collapse-row.selected {
  background: #E8F0E9;
  color: #7A9E7E;
}

/* ============================================
   8. 底部按钮组
   ============================================ */

.designer-panel-footer {
  padding: 16px 20px;
  border-top: 1px solid #E8E8E5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FFFFFF;
}

/* ============================================
   9. 覆盖原有 .editor-page 样式
   ============================================ */

/* 当编辑器使用新 UI 时，隐藏旧样式 */
body.designer-new-ui .editor-page {
  padding-top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

body.designer-new-ui .editor-toolbar {
  display: none; /* 用新的 designer-toolbar 替代 */
}

body.designer-new-ui .editor-sidebar {
  display: none; /* 用新的 designer-left-panel 替代 */
}

body.designer-new-ui .editor-stats {
  display: none; /* 用新的 designer-right-panel 替代 */
}

body.designer-new-ui .editor-canvas {
  background: #F2F1EC;
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.designer-hex-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100'%3E%3Cpath d='M28 66L0 50V16L28 0l28 16v34L28 66zm0-17.3l17.3-10V23.3L28 13.3 10.7 23.3V38.7L28 48.7z' fill='%237A9E7E' fill-opacity='0.3'/%3E%3C/svg%3E");
  background-size: 56px 100px;
  z-index: 0;
}

/* 确保 designer-canvas-area 内的子元素正确定位 */
.designer-canvas-area {
  position: relative;
}

/* ============================================
   10. 响应式适配
   ============================================ */

@media (max-width: 1200px) {
  .designer-header,
  .designer-toolbar {
    padding: 0 20px;
  }
  .designer-header-left {
    gap: 20px;
    min-width: 0;
  }
  .designer-header-right {
    gap: 12px;
    flex-shrink: 0;
  }
  .designer-left-panel,
  .designer-right-panel {
    width: 200px;
  }
  .designer-nav-links a {
    font-size: 13px;
    padding: 6px 12px;
  }
}

@media (max-width: 1024px) {
  .designer-page {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .designer-header {
    height: auto;
    padding: 14px 16px;
    align-items: flex-start;
    gap: 12px;
  }
  .designer-header-left {
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .designer-nav-links {
    flex-wrap: wrap;
    row-gap: 6px;
    margin-left: -8px;
  }
  .designer-nav-links a {
    padding: 6px 8px 6px 16px;
    font-size: 12px;
  }
  .designer-header-right {
    width: auto;
    margin-left: auto;
    align-self: flex-start;
  }
  .designer-toolbar {
    height: auto;
    padding: 12px 16px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .designer-toolbar-actions {
    flex-wrap: wrap;
  }
  .designer-btn {
    width: auto;
    min-width: 88px;
    padding: 0 14px;
  }
  .designer-workspace {
    flex-direction: column;
  }
  .designer-left-panel,
  .designer-right-panel {
    width: 100%;
    max-height: none;
    border-left: none;
    border-right: none;
  }
  .designer-left-panel {
    border-bottom: 1px solid #E0E0DC;
  }
  .designer-right-panel {
    border-top: 1px solid #E0E0DC;
  }
  .designer-canvas-area {
    min-height: 56vh;
  }
  .designer-scene-preview {
    display: none;
  }
}

@media (max-width: 768px) {
  .designer-header {
    padding: 12px 14px;
  }
  .designer-logo-text {
    font-size: 14px;
    letter-spacing: 2px;
  }
  .designer-nav-links {
    display: none;
  }
  .designer-header-right {
    gap: 10px;
  }
  .designer-header-right a,
  .designer-header-right button {
    font-size: 12px;
  }
  .designer-toolbar {
    padding: 10px 14px;
    gap: 10px;
  }
  .designer-toolbar-actions {
    width: 100%;
    gap: 8px;
  }
  .designer-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
  .designer-btn-auto,
  .designer-btn-full {
    width: 100%;
  }
  .designer-left-panel,
  .designer-right-panel {
    max-height: 42vh;
  }
  .designer-panel-header {
    padding: 16px 16px 12px;
  }
  .designer-panel-content {
    padding: 0 16px 16px;
  }
  .designer-stats-section {
    margin: 0 16px 8px;
  }
  .designer-canvas-area {
    min-height: 48vh;
  }
}

/* 手机端提示 - 默认隐藏 */
.designer-mobile-hint {
  display: none;
}

@media (max-width: 900px) {
  .designer-workspace {
    flex-direction: column;
  }
  .designer-left-panel,
  .designer-right-panel {
    width: 100%;
    height: auto;
    max-height: 300px;
    border-right: none;
    border-left: none;
  }
  .designer-left-panel {
    border-bottom: 1px solid #E0E0DC;
  }
  .designer-right-panel {
    border-top: 1px solid #E0E0DC;
  }
  .designer-canvas-area {
    flex: 1;
    min-height: 400px;
  }
}

@media (max-width: 480px) {
  body.designer-new-ui .editor-canvas {
    height: auto;
    min-height: 48vh;
  }
  .designer-right-panel {
    display: none;
  }
  .designer-left-panel > .designer-panel-section:not(:first-child) {
    display: none;
  }
  .designer-left-panel > .designer-mobile-hint {
    display: block;
  }
}

/* ============================================
   11. 工具提示
   ============================================ */

.designer-tooltip {
  position: relative;
}

.designer-tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: #333333;
  color: #FFFFFF;
  font-size: 11px;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  margin-bottom: 4px;
}

.designer-tooltip:hover::after {
  opacity: 1;
}

/* ============================================
   12. 六边形网格背景 (画布用)
   ============================================ */

.designer-hex-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.15; /* 更轻的透明度 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100'%3E%3Cpath d='M28 66L0 50V16L28 0l28 16v34L28 66zm0-17.3l17.3-10V23.3L28 13.3 10.7 23.3V38.7L28 48.7z' fill='%237A9E7E' fill-opacity='0.3'/%3E%3C/svg%3E");
  background-size: 56px 100px;
}

/* ============================================
   13. 快捷键提示标签
   ============================================ */

.designer-shortcut-tag {
  display: inline-block;
  padding: 2px 6px;
  background: #F0F0EC;
  border-radius: 3px;
  font-size: 10px;
  color: #888888;
  font-family: 'JetBrains Mono', monospace;
  margin-left: 4px;
}

/* ============================================
   14. 场景选择下拉
   ============================================ */

#sceneSelect {
  background-image: none;
}

/* ============================================
   15. 状态指示
   ============================================ */

.designer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #777777;
}

.designer-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7A9E7E;
}

.designer-status-dot.warning {
  background: #FFE900;
}

.designer-status-dot.error {
  background: #FF4444;
}

/* ============================================
   16. 固定场景按钮（支持悬停预览）
   ============================================ */

.designer-scene-button-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.designer-scene-button {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #7A9E7E;
  border-radius: 10px;
  background: #7A9E7E;
  color: #FFFFFF;
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.designer-scene-button:hover {
  border-color: #7A9E7E;
  color: #7A9E7E;
  background: #FFFFFF;
}

.designer-scene-button.selected {
  background: #7A9E7E;
  border-color: #7A9E7E;
  color: #FFFFFF;
  font-weight: 500;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
}

