// 工作流设计器 - React Flow版本
// 变量定义
@header-height: 64px;
@toolbar-height: 56px;
@sidebar-width: 260px;
@container-padding: 24px;

// 主容器 - 覆盖父容器样式
.workflow-design-container {
  // 使用负边距抵消父容器的padding
  margin: -@container-padding;
  // 精确计算高度：视口高度 - header高度
  height: calc(100vh - @header-height);
  // 补偿左右padding
  width: calc(100% + @container-padding * 2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  // React Flow 样式覆盖
  .react-flow {
    width: 100% !important;
    height: 100% !important;

    &__renderer {
      width: 100% !important;
      height: 100% !important;
    }

    // 自定义控制按钮样式
    &__controls {
      button {
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid #e5e7eb;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease-in-out;

        &:hover {
          background: #f9fafb;
          border-color: #3b82f6;
        }
      }
    }

    // 小地图样式
    &__minimap {
      background: #f9fafb;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
  }

  // 内容区域
  .workflow-content-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    min-height: 0;

    // 节点面板区域
    .node-panel {
      width: @sidebar-width;
      background: #f8fafc;
      border-right: 1px solid #e5e7eb;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);

      // 面板头部
      .panel-header {
        padding: 16px;
        background: #ffffff;
        border-bottom: 1px solid #e5e7eb;

        h3 {
          margin: 0;
          font-size: 14px;
          font-weight: 600;
          color: #374151;
        }

        p {
          margin: 4px 0 0 0;
          font-size: 12px;
          color: #6b7280;
        }
      }

      // 节点分组
      .node-group {
        margin-bottom: 16px;

        .group-title {
          font-size: 12px;
          font-weight: 600;
          color: #4b5563;
          margin-bottom: 8px;
          padding: 4px 0;
          border-bottom: 1px solid #e5e7eb;
        }

        // 节点项
        .node-item {
          display: flex;
          align-items: center;
          gap: 8px;
          padding: 8px 12px;
          border-radius: 6px;
          border: 1px solid #e5e7eb;
          background: #ffffff;
          cursor: grab;
          transition: all 0.2s ease-in-out;
          margin-bottom: 6px;

          &:hover {
            background: #f9fafb;
            border-color: var(--node-color, #3b82f6);
            transform: translateX(2px);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
          }

          &:active {
            cursor: grabbing;
          }

          .node-icon {
            font-size: 16px;
            width: 20px;
            text-align: center;
          }

          .node-info {
            .node-name {
              font-size: 13px;
              font-weight: 500;
              color: #374151;
              line-height: 1.2;
            }

            .node-desc {
              font-size: 11px;
              color: #6b7280;
              line-height: 1.2;
              margin-top: 2px;
            }
          }
        }
      }

      // 使用提示
      .panel-tips {
        padding: 12px;
        background: #f1f5f9;
        border-top: 1px solid #e5e7eb;
        font-size: 11px;
        color: #64748b;
        line-height: 1.4;
      }
    }

    // 画布区域
    .workflow-canvas-area {
      flex: 1;
      position: relative;
      overflow: hidden;
      background: #f8fafc;

      // 画布状态面板
      .canvas-status {
        position: absolute;
        top: 12px;
        left: 12px;
        background: rgba(255, 255, 255, 0.95);
        padding: 8px 12px;
        border-radius: 6px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        font-size: 12px;
        color: #6b7280;
        z-index: 10;
        backdrop-filter: blur(4px);
      }
    }
  }

  // 响应式适配
  @media (max-width: 1024px) {
    .workflow-content-area .node-panel {
      width: 220px;
    }
  }

  @media (max-width: 768px) {
    .workflow-content-area {
      flex-direction: column;

      .node-panel {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
      }
    }
  }
}

// 工具栏特殊样式
.workflow-toolbar {
  height: @toolbar-height;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;

  .toolbar-section {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .toolbar-title {
    h2 {
      margin: 0;
      font-size: 16px;
      font-weight: 600;
      color: #374151;
    }

    .subtitle {
      font-size: 12px;
      color: #6b7280;
      margin-top: 2px;
    }
  }

  .toolbar-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #6b7280;

    .status-item {
      background: #f3f4f6;
      padding: 4px 8px;
      border-radius: 4px;
      font-family: 'Monaco', 'Menlo', monospace;
    }

    .react-flow-badge {
      background: #ecfdf5;
      color: #065f46;
      padding: 4px 8px;
      border-radius: 4px;
      font-weight: 500;
    }
  }
}
