.workflow-designer {
  height: calc(100vh - 84px);
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
  overflow: hidden;

  .toolbar {
    height: 50px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;

    .toolbar-left, .toolbar-right {
      display: flex;
      align-items: center;
    }
  }

  .main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
  }

  .node-panel {
    width: 240px;
    background: #fff;
    border-right: 1px solid #e8e8e8;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-track {
      background: #f8f9fa;
    }

    &::-webkit-scrollbar-thumb {
      background: #d0d0d0;
      border-radius: 3px;
      transition: background 0.2s;

      &:hover {
        background: #b0b0b0;
      }
    }

    .panel-title {
      padding: 16px 20px;
      font-weight: 600;
      font-size: 15px;
      background: #1890ff;
      color: #fff;
      border-bottom: none;
      box-shadow: 0 2px 8px rgba(24, 144, 255, 0.15);
    }

    .node-category {
      margin-bottom: 4px;

      .category-title {
        padding: 12px 20px 8px;
        font-size: 12px;
        font-weight: 600;
        color: #666;
        background: #fafafa;
        display: flex;
        align-items: center;
        position: relative;

        &::before {
          content: '';
          display: inline-block;
          width: 3px;
          height: 12px;
          background: #1890ff;
          border-radius: 2px;
          margin-right: 8px;
        }
      }

      .node-list {
        padding: 12px 16px;
        background: #fff;
      }

      .node-item {
        display: flex;
        align-items: center;
        padding: 10px 14px;
        margin-bottom: 10px;
        background: #fff;
        border: 2px solid;
        border-radius: 8px;
        cursor: grab;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        overflow: hidden;

        &::before {
          content: '';
          position: absolute;
          left: 0;
          top: 0;
          bottom: 0;
          width: 4px;
          background: var(--node-color, currentColor);
          opacity: 0;
          transition: opacity 0.25s;
        }

        &:hover {
          transform: translateX(4px);
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
          
          &::before {
            opacity: 1;
          }
        }

        &:active {
          cursor: grabbing;
          transform: scale(0.98) translateX(4px);
        }

        &:last-child {
          margin-bottom: 0;
        }

        i {
          font-size: 18px;
          margin-right: 10px;
          flex-shrink: 0;
        }

        span {
          font-size: 13px;
          font-weight: 500;
          color: #333;
          flex: 1;
        }
      }
    }
  }

  .canvas-container {
    flex: 1;
    position: relative;
    overflow: auto;
    background: #f8f9fa;

    &::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }

    &::-webkit-scrollbar-track {
      background: #f1f1f1;
      border-radius: 4px;
    }

    &::-webkit-scrollbar-thumb {
      background: #c1c1c1;
      border-radius: 4px;
      transition: background 0.2s;

      &:hover {
        background: #a8a8a8;
      }
    }

    // 右键菜单样式
    .context-menu {
      position: absolute;
      background: #fff;
      border-radius: 8px;
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
      padding: 6px 0;
      min-width: 160px;
      z-index: 1000;
      user-select: none;

      .menu-item {
        padding: 8px 12px;
        display: flex;
        align-items: center;
        gap: 10px;
        cursor: pointer;
        transition: background 0.2s;
        font-size: 13px;
        color: #333;

        &:hover {
          background: #f5f7fa;
        }

        &.danger {
          color: #f56c6c;

          &:hover {
            background: #fef0f0;
          }
        }

        &.disabled {
          color: #999;
          cursor: not-allowed;

          &:hover {
            background: transparent;
          }
        }

        i {
          font-size: 14px;
          width: 14px;
          text-align: center;
          flex-shrink: 0;
        }

        > span:first-of-type {
          flex: 1;
          white-space: nowrap;
        }

        .shortcut {
          font-size: 11px;
          color: #999;
          font-family: 'Courier New', monospace;
          background: #f5f5f5;
          padding: 2px 6px;
          border-radius: 3px;
          flex-shrink: 0;
        }
      }

      .menu-divider {
        height: 1px;
        background: #e8e8e8;
        margin: 6px 0;
      }
    }

    .canvas-svg {
      min-width: 100%;
      min-height: 100%;
      cursor: grab;

      &.dragging-canvas {
        cursor: grabbing;
      }

      .node-group {
        cursor: move;

        rect {
          transition: stroke-width 0.2s, filter 0.2s;

          &.selected {
            stroke-width: 4;
            filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
          }
        }

        &.selected {
          .node-name {
            font-weight: 600;
          }
        }

        .node-content {
          display: flex;
          align-items: center;
          height: 100%;
          padding: 0 10px;
          overflow: hidden;

          i {
            font-size: 16px;
            margin-right: 6px;
            flex-shrink: 0;
          }

          .node-name {
            font-size: 12px;
            color: #333;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            flex: 1;
            min-width: 0;
          }
        }

        .anchor {
          opacity: 0;
          cursor: crosshair;
          transition: opacity 0.2s;
        }

        &:hover .anchor {
          opacity: 1;
        }
      }

      .edge-group {
        cursor: pointer;

        // 交互路径 - 扩大点击区域
        .edge-interaction {
          pointer-events: stroke;
        }

        .edge-path {
          transition: all 0.2s;
          pointer-events: none; // 让点击事件穿透到交互路径
        }

        // 悬停效果
        &:hover {
          .edge-path {
            stroke-width: 3;
            filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
          }
        }

        // 选中效果
        &.selected {
          .edge-path {
            stroke-width: 3;
            filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
          }
        }
      }
    }
  }

  .property-panel {
    width: 380px;
    background: #fff;
    border-left: 1px solid #e8e8e8;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-track {
      background: #f8f9fa;
    }

    &::-webkit-scrollbar-thumb {
      background: #d0d0d0;
      border-radius: 3px;
      transition: background 0.2s;

      &:hover {
        background: #b0b0b0;
      }
    }

    .panel-title {
      padding: 16px 20px;
      font-weight: 600;
      font-size: 15px;
      background: #1890ff;
      color: #fff;
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-shadow: 0 2px 8px rgba(24, 144, 255, 0.15);

      span {
        display: flex;
        align-items: center;
        
        i {
          margin-right: 8px;
          font-size: 16px;
        }
      }

      .el-icon-close {
        cursor: pointer;
        color: rgba(255, 255, 255, 0.8);
        font-size: 18px;
        transition: all 0.2s;

        &:hover {
          color: #fff;
          transform: rotate(90deg);
        }
      }
    }

    .property-content {
      flex: 1;
      overflow-y: auto;
    }

    .el-form {
      padding: 0;
    }

    // 节点类型徽章样式
    .node-type-badge {
      display: inline-flex;
      align-items: center;
      padding: 8px 16px;
      background: rgba(24, 144, 255, 0.08);
      border: 1px solid rgba(24, 144, 255, 0.2);
      border-radius: 20px;
      font-size: 13px;
      color: #333;
      font-weight: 500;
      transition: all 0.2s;

      &:hover {
        background: rgba(24, 144, 255, 0.15);
        border-color: rgba(24, 144, 255, 0.3);
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(24, 144, 255, 0.15);
      }

      i {
        font-size: 16px;
        margin-right: 8px;
      }

      span {
        line-height: 1;
      }
    }

    .property-section {
      margin-bottom: 8px;
      background: #fff;
      border-radius: 8px;
      overflow: hidden;

      .section-title {
        padding: 12px 20px;
        margin-bottom: 16px;
        font-size: 13px;
        font-weight: 600;
        color: #333;
        background: #f7f8fa;
        border-bottom: 1px solid #e8e8e8;
        display: flex;
        align-items: center;

        i {
          margin-right: 8px;
          color: #1890ff;
          font-size: 14px;
        }
      }

      .el-form-item {
        margin-bottom: 18px;
        padding: 0 20px;

        &:first-of-type {
          margin-top: 4px;
        }

        &:last-child {
          margin-bottom: 12px;
        }
      }
    }

    .form-row {
      display: flex;
      gap: 12px;
      padding: 0 20px;

      .el-form-item {
        padding: 0;
        
        &.half-width {
          flex: 1;
        }
      }
    }

    .property-actions {
      padding: 16px 20px;
      border-top: 1px solid #e8e8e8;
      background: #fafafa;
      display: flex;
      gap: 10px;

      .el-button {
        flex: 1;
        border-radius: 6px;
        font-weight: 500;
      }
    }

    // 表单样式优化
    .el-input,
    .el-select,
    .el-textarea {
      .el-input__inner,
      .el-textarea__inner {
        border-radius: 6px;
        border-color: #e0e0e0;
        transition: all 0.2s;

        &:focus {
          border-color: #1890ff;
          box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
        }
      }
    }

    .el-input-number {
      width: 100%;

      .el-input__inner {
        border-radius: 6px;
        text-align: left;
      }
    }

    .el-radio-group {
      .el-radio {
        margin-right: 20px;

        &:last-child {
          margin-right: 0;
        }
      }
    }

    .el-color-picker {
      .el-color-picker__trigger {
        border-radius: 6px;
        border: 1px solid #e0e0e0;
        transition: all 0.2s;

        &:hover {
          border-color: #667eea;
        }
      }
    }

    // 条件判断样式
    .add-condition-btn {
      margin-left: auto;
      border-radius: 4px;
      font-size: 12px;
    }

    .conditions-container {
      padding: 12px 20px;
    }

    .condition-item {
      background: #f9fafb;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      padding: 12px;
      margin-bottom: 12px;
      transition: all 0.2s;

      &:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border-color: #667eea;
      }

      &:last-child {
        margin-bottom: 0;
      }

      .condition-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px dashed #e5e7eb;

        .condition-number {
          font-size: 13px;
          font-weight: 600;
          color: #667eea;
          display: flex;
          align-items: center;

          &::before {
            content: '';
            display: inline-block;
            width: 4px;
            height: 4px;
            background: #667eea;
            border-radius: 50%;
            margin-right: 6px;
          }
        }

        .el-button {
          padding: 6px;
        }
      }

      .condition-content {
        .el-form-item {
          margin-bottom: 12px;
          padding: 0;

          &:last-child {
            margin-bottom: 0;
          }
        }
      }
    }

    .empty-condition {
      text-align: center;
      padding: 32px 20px;
      color: #999;
      font-size: 13px;

      i {
        font-size: 32px;
        color: #d0d0d0;
        display: block;
        margin-bottom: 8px;
      }
    }
  }
}
